updated Code add logger
This commit is contained in:
+11
-11
@@ -10,15 +10,15 @@ import lombok.Setter;
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class FetchBillForwardRequest {
|
public class FetchBillForwardRequest {
|
||||||
private String billerId;
|
private String billerId;
|
||||||
private String billerName;
|
private String billerName;
|
||||||
private String billerCategory;
|
private String billerCategory;
|
||||||
private String clientReqId;
|
private String clientReqId;
|
||||||
private String macAdress;
|
private String macAdress;
|
||||||
private String customerMobNo;
|
private String customerMobNo;
|
||||||
private String remitterName;
|
private String remitterName;
|
||||||
private String paymentChannel;
|
private String paymentChannel;
|
||||||
private List<Tag> deviceBlockTags;
|
private List<Tag> deviceBlockTags;
|
||||||
private CustomerParamsRequest customerParamsRequest;
|
private CustomerParamsRequest customerParamsRequest;
|
||||||
private List<RemitterIdentity> remitterIdentity;
|
private List<RemitterIdentity> remitterIdentity;
|
||||||
}
|
}
|
||||||
|
|||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
package com.billpaymentservice.bbps.dto.sentRequest;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class FetchComplaintForwardRequest {
|
||||||
|
|
||||||
|
private String ticketDescription; // Complaint description that the user enters
|
||||||
|
private String ticketDisposition; // Complaint disposition
|
||||||
|
private String ticketDispositionCode; // Type of complaint
|
||||||
|
private String txnId; // Transaction ID (optional)
|
||||||
|
private String billerId; // Client Req ID (optional);
|
||||||
|
private String billerName;
|
||||||
|
|
||||||
|
}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
package com.billpaymentservice.bbps.dto.sentRequest;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class FetchTicketLatestStatusRequest {
|
||||||
|
|
||||||
|
private String txnNpciId;
|
||||||
|
|
||||||
|
private String ticketId;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package com.billpaymentservice.bbps.entites;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.billpaymentservice.bbps.audit.Auditable;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
|
||||||
import jakarta.persistence.CascadeType;
|
import jakarta.persistence.CascadeType;
|
||||||
@@ -35,7 +36,7 @@ import lombok.ToString;
|
|||||||
|
|
||||||
@Table(name = "biller_details")
|
@Table(name = "biller_details")
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public class BillerDetails {
|
public class BillerDetails{
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "biller_id", length = 14, nullable = false, unique = true)
|
@Column(name = "biller_id", length = 14, nullable = false, unique = true)
|
||||||
|
|||||||
@@ -75,15 +75,16 @@ public class AgentServiceImpl implements AgentService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseModel initiateBillFetch(FetchBillRequest fetchBillRequest) {
|
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 apiName = "InitiateBillFetch";
|
||||||
String txnId = helper.generateTxnId(15);
|
|
||||||
String requestId = fetchBillRequest.getReqId();
|
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;
|
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_INTI;
|
||||||
fetchBillRequest.setClientReqId(txnId);
|
fetchBillRequest.setClientReqId(txnId);
|
||||||
helper.validateMerchant(fetchBillRequest.getMid());
|
|
||||||
|
|
||||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
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);
|
LOGGER.debug("Outbound log created successfully for txnId: {} and reqId: {}", txnId, requestId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LOGGER.info("Calling external API: {}", fullUrl);
|
LOGGER.info("[{}] Calling external API | URL={}", apiName, fullUrl);
|
||||||
Map<String, String> responseMap = httpService.postRequest(fullUrl, forwardJson, headers);
|
Map<String, String> responseMap = httpService.postRequest(fullUrl, forwardJson, headers);
|
||||||
String responseData = responseMap.get("data");
|
String responseData = responseMap.get("data");
|
||||||
|
|
||||||
@@ -154,6 +155,7 @@ public class AgentServiceImpl implements AgentService {
|
|||||||
LOGGER.warn("Thread interrupted during delay: {}", e.getMessage());
|
LOGGER.warn("Thread interrupted during delay: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
LOGGER.info("Calling internal method Fetching bill by ID: {}", billFetchByBillIdRequest.getBillId());
|
LOGGER.info("Calling internal method Fetching bill by ID: {}", billFetchByBillIdRequest.getBillId());
|
||||||
|
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResponse.getStatus());
|
||||||
return fetchBillById(billFetchByBillIdRequest, inboundLog);
|
return fetchBillById(billFetchByBillIdRequest, inboundLog);
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
LOGGER.error("JSON Parsing Error: {}", e.getMessage(), e);
|
LOGGER.error("JSON Parsing Error: {}", e.getMessage(), e);
|
||||||
@@ -223,86 +225,89 @@ public class AgentServiceImpl implements AgentService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseModel fetchBillById(BillFetchByBillIdRequest billFetchByBillIdRequest) {
|
public ResponseModel fetchBillById(BillFetchByBillIdRequest billFetchByBillIdRequest) {
|
||||||
String apiName = "FetchBillById";
|
String apiName = "FetchBillById";
|
||||||
String txnId = helper.generateTxnId(15);
|
String reqId = billFetchByBillIdRequest.getReqId();
|
||||||
String reqId = billFetchByBillIdRequest.getReqId();
|
String billId = billFetchByBillIdRequest.getBillId();
|
||||||
String billId = billFetchByBillIdRequest.getBillId();
|
String mid = billFetchByBillIdRequest.getMid();
|
||||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + billFetchByBillIdRequest.getBillId();
|
|
||||||
|
|
||||||
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)
|
helper.validateMerchant(mid);
|
||||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName,
|
String txnId = helper.generateTxnId(15);
|
||||||
billFetchByBillIdRequest.getMid(), "GET", null);
|
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + billFetchByBillIdRequest.getBillId();
|
||||||
|
|
||||||
try {
|
LOGGER.info("Initiating {} API for billId={} and reqId={}", apiName, billId, reqId);
|
||||||
helper.validateMerchant(billFetchByBillIdRequest.getMid());
|
|
||||||
LOGGER.debug("Merchant validated successfully for MID={}", billFetchByBillIdRequest.getMid());
|
|
||||||
|
|
||||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
// create inbound log (GET -> no request body)
|
||||||
HttpHeaders headers = new HttpHeaders();
|
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, billFetchByBillIdRequest.getMid(),
|
||||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
"GET", null);
|
||||||
headers.set("agentId", headersData.getAgentId());
|
|
||||||
headers.set("tenantId", headersData.getTenantId());
|
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
||||||
|
|
||||||
// create outbound log
|
try {
|
||||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
LOGGER.debug("Merchant validated successfully for MID={}", billFetchByBillIdRequest.getMid());
|
||||||
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);
|
|
||||||
|
|
||||||
// update outbound log with response
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
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();
|
// create outbound log
|
||||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||||
new TypeReference<Map<String, Object>>() {
|
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")) {
|
// update outbound log with response
|
||||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
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")));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BillDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillDataResponse.class);
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
new TypeReference<Map<String, Object>>() {
|
||||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
});
|
||||||
|
|
||||||
// update inbound log success and persist bill data
|
if (!dataMap.containsKey("genericResponse")) {
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||||
helper.saveOrUpdateBillData(responseWrapper, billFetchByBillIdRequest, txnId);
|
LOGGER.warn("Invalid response structure received for billId={} | Response={}", billId, responseData);
|
||||||
LOGGER.info("Bill data saved successfully for billId={} | Status={}", billId, generalResp.getStatus());
|
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) {
|
// update inbound log success and persist bill data
|
||||||
LOGGER.error("Error parsing responseData JSON for billId={} : {}", billId, e.getMessage(), e);
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
helper.saveOrUpdateBillData(responseWrapper, billFetchByBillIdRequest, txnId);
|
||||||
throw new CustomException("Invalid JSON received from API");
|
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
|
@Override
|
||||||
public ResponseModel initiateBillValidate(FetchBillValidatestRequest fetchBillValidateRequest) {
|
public ResponseModel initiateBillValidate(FetchBillValidatestRequest fetchBillValidateRequest) {
|
||||||
LOGGER.info("Initiating bill Validate for request ID: {} and MID:{} and billerId:{}", fetchBillValidateRequest.getReqId(),
|
|
||||||
fetchBillValidateRequest.getMid(),fetchBillValidateRequest.getBillerId());
|
|
||||||
|
|
||||||
String apiName = "InitiateBillValidate";
|
String apiName = "InitiateBillValidate";
|
||||||
String txnId = helper.generateTxnId(15);
|
|
||||||
String reqId = fetchBillValidateRequest.getReqId();
|
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;
|
String fullUrl = agentDtaUrl + BBPSConstant.BILLER_VALIDATE_URL;
|
||||||
fetchBillValidateRequest.setClientReqId(txnId);
|
fetchBillValidateRequest.setClientReqId(txnId);
|
||||||
helper.validateMerchant(fetchBillValidateRequest.getMid());
|
|
||||||
|
|
||||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
HttpHeaders headers = new HttpHeaders();
|
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);
|
LOGGER.debug("Outbound log created successfully for txnId: {} and reqId: {}", txnId, reqId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LOGGER.info("Calling external API: {}", fullUrl);
|
LOGGER.info("[{}] Calling external API | URL={}", apiName, fullUrl);
|
||||||
Map<String, String> responseMap = httpService.postRequest(fullUrl, forwardJson, headers);
|
Map<String, String> responseMap = httpService.postRequest(fullUrl, forwardJson, headers);
|
||||||
String responseData = responseMap.get("data");
|
String responseData = responseMap.get("data");
|
||||||
|
|
||||||
@@ -375,6 +380,7 @@ public class AgentServiceImpl implements AgentService {
|
|||||||
LOGGER.warn("Thread interrupted during delay: {}", e.getMessage());
|
LOGGER.warn("Thread interrupted during delay: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
LOGGER.info("Calling internal method Fetching bill by ID: {}", billFetchByBillIdRequest.getBillId());
|
LOGGER.info("Calling internal method Fetching bill by ID: {}", billFetchByBillIdRequest.getBillId());
|
||||||
|
LOGGER.info("[{}] END | reqId={} | status={}", apiName, reqId, generalResponse.getStatus());
|
||||||
return BillvaidateByBillId(billFetchByBillIdRequest, inboundLog);
|
return BillvaidateByBillId(billFetchByBillIdRequest, inboundLog);
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
LOGGER.error("JSON Parsing Error: {}", e.getMessage(), e);
|
LOGGER.error("JSON Parsing Error: {}", e.getMessage(), e);
|
||||||
@@ -452,13 +458,16 @@ public class AgentServiceImpl implements AgentService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseModel initiateBillValidateByBillId(BillFetchByBillIdRequest billRequest) {
|
public ResponseModel initiateBillValidateByBillId(BillFetchByBillIdRequest billRequest) {
|
||||||
String apiName = "FetchBillById";
|
String apiName = "FetchBillById";
|
||||||
String txnId = helper.generateTxnId(15);
|
|
||||||
String reqId = billRequest.getReqId();
|
String reqId = billRequest.getReqId();
|
||||||
String billId = billRequest.getBillId();
|
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();
|
String fullUrl = agentDtaUrl + BBPSConstant.BILL_VALIDATE_ID_URL + billRequest.getBillId();
|
||||||
|
|
||||||
LOGGER.info("Initiating {} API for billId={} and reqId={}", apiName, billId, reqId);
|
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);
|
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, billRequest.getMid(), "GET", null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
helper.validateMerchant(billRequest.getMid());
|
|
||||||
|
|
||||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
@@ -488,26 +496,29 @@ public class AgentServiceImpl implements AgentService {
|
|||||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
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")) {
|
if (!dataMap.containsKey("genericResponse")) {
|
||||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||||
LOGGER.warn("Invalid response structure received for billId={} | Response={}", billId, responseData);
|
LOGGER.warn("Invalid response structure received for billId={} | Response={}", billId, responseData);
|
||||||
throw new CustomException(String.valueOf(dataMap.get("message")),
|
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||||
String.valueOf(dataMap.get("status")),
|
|
||||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||||
String.valueOf(dataMap.get("remarks")));
|
String.valueOf(dataMap.get("remarks")));
|
||||||
}
|
}
|
||||||
|
|
||||||
FetchBillValidateResponse responseWrapper = objectMapper.convertValue(dataMap, FetchBillValidateResponse.class);
|
FetchBillValidateResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||||
|
FetchBillValidateResponse.class);
|
||||||
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||||
|
|
||||||
// update inbound log and save validation data
|
// update inbound log and save validation data
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
helper.saveBillValidation(responseWrapper, billRequest);
|
helper.saveBillValidation(responseWrapper, billRequest);
|
||||||
LOGGER.info("Bill validation saved successfully for billId: {}", billId);
|
LOGGER.info("Bill validation saved successfully for billId: {}", billId);
|
||||||
|
LOGGER.info("[{}] END | reqId={} | status={}", apiName, reqId, 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 (com.fasterxml.jackson.core.JsonProcessingException e) {
|
} catch (com.fasterxml.jackson.core.JsonProcessingException e) {
|
||||||
LOGGER.error("Error parsing ValidateByBillId JSON: {}", e.getMessage(), 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");
|
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
|
@Override
|
||||||
public ResponseModel fetchBillValidateByClientReqId(BillValidateByClientIdRequest billValidateByClientIdRequest) {
|
public ResponseModel fetchBillValidateByClientReqId(BillValidateByClientIdRequest billValidateByClientIdRequest) {
|
||||||
|
|
||||||
String apiName = "FetchBillValidateByClientIdRequest";
|
String apiName = "FetchBillValidateByClientIdRequest";
|
||||||
String txnId = helper.generateTxnId(15);
|
|
||||||
String reqId = billValidateByClientIdRequest.getReqId();
|
String reqId = billValidateByClientIdRequest.getReqId();
|
||||||
String clientReqId = billValidateByClientIdRequest.getClientReqId();
|
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);
|
Optional<BillInitiate> billInitiate = billIntiateRepository.findByReqId(clientReqId);
|
||||||
if (billInitiate.isEmpty()) {
|
if (billInitiate.isEmpty()) {
|
||||||
throw new CustomException("No Bill Found for given Client Req Id");
|
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();
|
String fullUrl = agentDtaUrl + BBPSConstant.BILL_VALIDATE_BY_CLIENT_REQ_ID + billInitiate.get().getTxnId();
|
||||||
|
|
||||||
helper.validateMerchant(billValidateByClientIdRequest.getMid());
|
|
||||||
|
|
||||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
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);
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||||
|
|
||||||
try {
|
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);
|
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||||
String responseData = responseMap.get("data");
|
String responseData = responseMap.get("data");
|
||||||
|
|
||||||
@@ -575,7 +588,7 @@ public class AgentServiceImpl implements AgentService {
|
|||||||
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||||
|
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
|
LOGGER.info("[{}] END | reqId={} | status={}", apiName, reqId, generalResp.getStatus());
|
||||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||||
|
|
||||||
@@ -589,9 +602,14 @@ public class AgentServiceImpl implements AgentService {
|
|||||||
public ResponseModel fetchBillByClientReqId(BillFetchByClientIdRequest billFetchByClientIdRequest) {
|
public ResponseModel fetchBillByClientReqId(BillFetchByClientIdRequest billFetchByClientIdRequest) {
|
||||||
|
|
||||||
String apiName = "FetchBillByClientIdRequest";
|
String apiName = "FetchBillByClientIdRequest";
|
||||||
String txnId = helper.generateTxnId(15);
|
|
||||||
String reqId = billFetchByClientIdRequest.getReqId();
|
String reqId = billFetchByClientIdRequest.getReqId();
|
||||||
String clientReqId = billFetchByClientIdRequest.getClientReqId();
|
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);
|
Optional<BillInitiate> billInitiate = billIntiateRepository.findByReqId(clientReqId);
|
||||||
if (billInitiate.isEmpty()) {
|
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();
|
String fullUrl = agentDtaUrl + BBPSConstant.BILL_VALIDATE_BY_CLIENT_REQ_ID + billInitiate.get().getTxnId();
|
||||||
|
|
||||||
helper.validateMerchant(billFetchByClientIdRequest.getMid());
|
|
||||||
|
|
||||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
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);
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||||
|
|
||||||
try {
|
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);
|
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||||
String responseData = responseMap.get("data");
|
String responseData = responseMap.get("data");
|
||||||
|
|
||||||
@@ -639,7 +655,7 @@ public class AgentServiceImpl implements AgentService {
|
|||||||
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||||
|
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
|
LOGGER.info("[{}] END | reqId={} | status={}", apiName, reqId, generalResp.getStatus());
|
||||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||||
|
|
||||||
@@ -649,7 +665,6 @@ public class AgentServiceImpl implements AgentService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @Override public ResponseModel
|
* @Override public ResponseModel
|
||||||
* initiateBillValidate(FetchBillValidatestRequest fetchBillValidateRequest) {
|
* 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.GetTicketLatestStausRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.TxnStatusRequest;
|
import com.billpaymentservice.bbps.dto.request.TxnStatusRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.ViewAllComplaintsTicketsRequest;
|
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.ComplaintHistoryStatusResponse;
|
||||||
import com.billpaymentservice.bbps.dto.response.ComplaintResponse;
|
import com.billpaymentservice.bbps.dto.response.ComplaintResponse;
|
||||||
import com.billpaymentservice.bbps.dto.response.TicketCheckStatusResponse;
|
import com.billpaymentservice.bbps.dto.response.TicketCheckStatusResponse;
|
||||||
import com.billpaymentservice.bbps.dto.response.TxnStatusResponse;
|
import com.billpaymentservice.bbps.dto.response.TxnStatusResponse;
|
||||||
|
|
||||||
import com.billpaymentservice.bbps.dto.response.ViewAllComplaintsTicketsResponse;
|
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.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.BharatConnectMaster;
|
||||||
import com.billpaymentservice.bbps.entites.ComplaintStatusOptionsMaster;
|
import com.billpaymentservice.bbps.entites.ComplaintStatusOptionsMaster;
|
||||||
import com.billpaymentservice.bbps.entites.InboundTraceLog;
|
import com.billpaymentservice.bbps.entites.InboundTraceLog;
|
||||||
@@ -83,19 +81,16 @@ public class ComplainServiceImpl implements ComplainService {
|
|||||||
@Override
|
@Override
|
||||||
public ResponseModel addComplain(ComplaintRequestDTO complainRequestDTO) {
|
public ResponseModel addComplain(ComplaintRequestDTO complainRequestDTO) {
|
||||||
|
|
||||||
LOGGER.info("Initiating add Complain for request ID: {} and MID {}", complainRequestDTO.getReqId(),
|
|
||||||
complainRequestDTO.getMid());
|
|
||||||
|
|
||||||
String apiName = "ADD_COMPLAIN";
|
String apiName = "ADD_COMPLAIN";
|
||||||
String txnId = helper.generateTxnId(15);
|
|
||||||
String requestId = complainRequestDTO.getReqId();
|
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;
|
String fullUrl = complainDataUrl + BBPSConstant.ADD_COMPLAIN_ENDPOINT;
|
||||||
|
LOGGER.info("[{}] Full URL={}", apiName, fullUrl);
|
||||||
LOGGER.info("Full URL-: "+ fullUrl);
|
|
||||||
|
|
||||||
// Convert input DTO to JSON
|
|
||||||
String requestJson = helper.convertObjectToJson(complainRequestDTO);
|
|
||||||
|
|
||||||
// Fetch tenant & agent from DB
|
// Fetch tenant & agent from DB
|
||||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
|
|
||||||
@@ -104,25 +99,33 @@ public class ComplainServiceImpl implements ComplainService {
|
|||||||
headers.set("agentId", headersData.getAgentId());
|
headers.set("agentId", headersData.getAgentId());
|
||||||
headers.set("tenantId", headersData.getTenantId());
|
headers.set("tenantId", headersData.getTenantId());
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
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(),
|
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, complainRequestDTO.getMid(),
|
||||||
"POST", requestJson);
|
"POST", requestJson);
|
||||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, fullUrl, "POST", null);
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, fullUrl, "POST",
|
||||||
|
forwardJson);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Inject tenantId + agentId into request JSON
|
// 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("tenantId", headersData.getTenantId());
|
||||||
root.put("agentId", headersData.getAgentId());
|
root.put("agentId", headersData.getAgentId());
|
||||||
|
|
||||||
String finalJson = root.toString();
|
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
|
// IMPORTANT: Send finalJson, not requestJson
|
||||||
Map<String, String> responseMap = httpService.postRequest(fullUrl, finalJson, headers);
|
Map<String, String> responseMap = httpService.postRequest(fullUrl, finalJson, headers);
|
||||||
|
|
||||||
String responseData = responseMap.get("data");
|
String responseData = responseMap.get("data");
|
||||||
LOGGER.info("Fetched response: {}", responseData);
|
LOGGER.debug("[{}] Response Received | reqId={} | data={}", apiName, requestId, responseData);
|
||||||
|
|
||||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
|
|
||||||
@@ -133,7 +136,7 @@ public class ComplainServiceImpl implements ComplainService {
|
|||||||
if (start != -1 && end != -1) {
|
if (start != -1 && end != -1) {
|
||||||
responseData = responseData.substring(start, 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
|
// Parse JSON into Map
|
||||||
@@ -145,6 +148,7 @@ public class ComplainServiceImpl implements ComplainService {
|
|||||||
|
|
||||||
// Throw exception for non-200
|
// Throw exception for non-200
|
||||||
if (statusCode != 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")),
|
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||||
statusCode, String.valueOf(dataMap.get("remarks")));
|
statusCode, String.valueOf(dataMap.get("remarks")));
|
||||||
}
|
}
|
||||||
@@ -156,6 +160,7 @@ public class ComplainServiceImpl implements ComplainService {
|
|||||||
Integer.parseInt(responseWrapper.getStatusCode()), responseWrapper);
|
Integer.parseInt(responseWrapper.getStatusCode()), responseWrapper);
|
||||||
|
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, responseWrapper.getStatus());
|
helper.updateInboundLogSuccess(inboundLog, responseData, responseWrapper.getStatus());
|
||||||
|
LOGGER.info("[{}] SUCCESS | reqId={} | status={}", apiName, requestId, responseWrapper.getStatus());
|
||||||
return responseModel;
|
return responseModel;
|
||||||
|
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
@@ -171,13 +176,17 @@ public class ComplainServiceImpl implements ComplainService {
|
|||||||
LOGGER.info("Fetching Complaint Status for TicketId={} ReqId={}", request.getTicketId(), request.getReqId());
|
LOGGER.info("Fetching Complaint Status for TicketId={} ReqId={}", request.getTicketId(), request.getReqId());
|
||||||
|
|
||||||
String apiName = "COMPLAINT_STATUS";
|
String apiName = "COMPLAINT_STATUS";
|
||||||
String txnId = helper.generateTxnId(15);
|
|
||||||
String reqId = request.getReqId();
|
String reqId = request.getReqId();
|
||||||
String complaintId = request.getTicketId();
|
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;
|
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");
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
@@ -187,27 +196,32 @@ public class ComplainServiceImpl implements ComplainService {
|
|||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
// Convert request to 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);
|
String requestJson = helper.convertObjectToJson(request);
|
||||||
|
|
||||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), "POST",
|
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), "POST",
|
||||||
requestJson);
|
requestJson);
|
||||||
|
|
||||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "POST", complaintId);
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "POST", forwardJson);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
ObjectNode root = (ObjectNode) objectMapper.readTree(requestJson);
|
ObjectNode root = (ObjectNode) objectMapper.readTree(forwardJson);
|
||||||
root.put("tenantId", headersData.getTenantId());
|
root.put("tenantId", headersData.getTenantId());
|
||||||
//root.put("agentId", headersData.getAgentId());
|
// root.put("agentId", headersData.getAgentId());
|
||||||
|
|
||||||
String finalJson = root.toString();
|
String finalJson = root.toString();
|
||||||
LOGGER.info("Final Request Sent to API: {}", finalJson);
|
LOGGER.info("[{}] Final API Payload | reqId={} | payload={}", apiName, reqId, finalJson);
|
||||||
// LOGGER.info("Calling external API: {}", fullUrl);
|
|
||||||
Map<String, String> responseMap = httpService.postRequest(fullUrl, finalJson, headers);
|
Map<String, String> responseMap = httpService.postRequest(fullUrl, finalJson, headers);
|
||||||
|
|
||||||
String responseData = responseMap.get("data");
|
String responseData = responseMap.get("data");
|
||||||
|
|
||||||
LOGGER.info("Complaint Fetch Response: {}", responseData);
|
LOGGER.debug("[{}] Raw Response | reqId={} | data={}", apiName, reqId, responseData);
|
||||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
|
|
||||||
if (responseData.startsWith("HttpService Error")) {
|
if (responseData.startsWith("HttpService Error")) {
|
||||||
@@ -227,20 +241,21 @@ public class ComplainServiceImpl implements ComplainService {
|
|||||||
int statusCode = Integer.parseInt(String.valueOf(dataMap.get("statusCode")));
|
int statusCode = Integer.parseInt(String.valueOf(dataMap.get("statusCode")));
|
||||||
|
|
||||||
if (statusCode != 200) {
|
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")),
|
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||||
statusCode, String.valueOf(dataMap.get("remarks")));
|
statusCode, String.valueOf(dataMap.get("remarks")));
|
||||||
}
|
}
|
||||||
|
|
||||||
TicketCheckStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
|
TicketCheckStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||||
TicketCheckStatusResponse.class);
|
TicketCheckStatusResponse.class);
|
||||||
|
LOGGER.info("[{}] Complaint Status | ticketId={} | status={}", apiName, ticketId,
|
||||||
LOGGER.info("Complaint Current Status: {}", responseWrapper.getStatus());
|
responseWrapper.getStatus());
|
||||||
|
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, responseWrapper.getStatus());
|
helper.updateInboundLogSuccess(inboundLog, responseData, responseWrapper.getStatus());
|
||||||
|
|
||||||
// Save in DB
|
// 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(),
|
return new ResponseModel(responseWrapper.getMessage(), responseWrapper.getStatus(),
|
||||||
Integer.parseInt(responseWrapper.getStatusCode()), responseWrapper);
|
Integer.parseInt(responseWrapper.getStatusCode()), responseWrapper);
|
||||||
|
|
||||||
@@ -255,16 +270,17 @@ public class ComplainServiceImpl implements ComplainService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseModel viewComplaintHistory(ComplainStatusRequest request) {
|
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 apiName = "View_Complaint_History";
|
||||||
String txnId = helper.generateTxnId(15);
|
|
||||||
String reqId = request.getReqId();
|
String reqId = request.getReqId();
|
||||||
String ticketId = request.getTicketId();
|
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();
|
String fullUrl = agentDtaUrl + BBPSConstant.COMPLAINT_HISTORY + request.getTicketId();
|
||||||
|
|
||||||
helper.validateMerchant(request.getMid());
|
helper.validateMerchant(request.getMid());
|
||||||
|
String txnId = helper.generateTxnId(15);
|
||||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
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",
|
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), "GET",
|
||||||
requestJson);
|
requestJson);
|
||||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", ticketId);
|
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 {
|
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);
|
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||||
String responseData = responseMap.get("data");
|
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);
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
|
|
||||||
@@ -294,8 +310,8 @@ public class ComplainServiceImpl implements ComplainService {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!dataMap.containsKey("generalResp")) {
|
if (!dataMap.containsKey("generalResp")) {
|
||||||
|
LOGGER.warn("[{}] Invalid response structure | reqId={} | data={}", apiName, reqId, responseData);
|
||||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
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")),
|
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), String.valueOf(""));
|
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), String.valueOf(""));
|
||||||
}
|
}
|
||||||
@@ -309,8 +325,8 @@ public class ComplainServiceImpl implements ComplainService {
|
|||||||
|
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
String saveComplaintHistory = mapperHelper.saveComplaintHistory(responseWrapper, reqId, txnId);
|
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(),
|
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
@@ -322,15 +338,16 @@ public class ComplainServiceImpl implements ComplainService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseModel viewComplaintById(ComplainStatusRequest request) {
|
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 apiName = "View_Complaint_By_ID";
|
||||||
String txnId = helper.generateTxnId(15);
|
|
||||||
String reqId = request.getReqId();
|
String reqId = request.getReqId();
|
||||||
String ticketId = request.getTicketId();
|
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());
|
helper.validateMerchant(request.getMid());
|
||||||
|
String txnId = helper.generateTxnId(15);
|
||||||
|
String fullUrl = agentDtaUrl + BBPSConstant.VIEW_COMPLAINT_BY_ID + request.getTicketId();
|
||||||
|
|
||||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
@@ -349,7 +366,7 @@ public class ComplainServiceImpl implements ComplainService {
|
|||||||
LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
|
LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
|
||||||
|
|
||||||
try {
|
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);
|
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||||
String responseData = responseMap.get("data");
|
String responseData = responseMap.get("data");
|
||||||
LOGGER.info("Complaint History Complaint FetchById Response: {}", responseData);
|
LOGGER.info("Complaint History Complaint FetchById Response: {}", responseData);
|
||||||
@@ -376,7 +393,7 @@ public class ComplainServiceImpl implements ComplainService {
|
|||||||
|
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
String saveComplaint = mapperHelper.saveComplainStatusDetail(responseWrapper, reqId, txnId);
|
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(),
|
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||||
@@ -391,15 +408,16 @@ public class ComplainServiceImpl implements ComplainService {
|
|||||||
public ResponseModel getAllActiveStatuses(AllMasterOptionsRequest request) {
|
public ResponseModel getAllActiveStatuses(AllMasterOptionsRequest request) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LOGGER.info("Fetch All Master Options - MID: {}", request.getMid());
|
|
||||||
String apiName = "View All Options Fetch By Id";
|
String apiName = "View All Options Fetch By Id";
|
||||||
String txnId = helper.generateTxnId(15);
|
|
||||||
String reqId = request.getReqId();
|
String reqId = request.getReqId();
|
||||||
String fullUrl = "Data Base Options";
|
String fullUrl = "Data Base Options";
|
||||||
|
String mid = request.getMid();
|
||||||
String requestJson = helper.convertObjectToJson(request);
|
LOGGER.info("[{}] START | reqId={} | mid={}", apiName, reqId, mid);
|
||||||
// Validate merchant
|
// 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",
|
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), "GET",
|
||||||
requestJson);
|
requestJson);
|
||||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||||
@@ -432,14 +450,16 @@ public class ComplainServiceImpl implements ComplainService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ResponseModel checkTxnStatus(TxnStatusRequest request) {
|
public ResponseModel checkTxnStatus(TxnStatusRequest request) {
|
||||||
LOGGER.info("Check Txn Status Request by Id={} and ReqId ={}", request.getId(), request.getReqId());
|
String apiName = "Check_Txn_Status";
|
||||||
String apiName = "CheckTxnStatus";
|
|
||||||
String txnId = helper.generateTxnId(15);
|
|
||||||
String reqId = request.getReqId();
|
String reqId = request.getReqId();
|
||||||
String ID = request.getId();
|
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());
|
helper.validateMerchant(request.getMid());
|
||||||
|
String txnId = helper.generateTxnId(15);
|
||||||
|
String fullUrl = agentDtaUrl + BBPSConstant.CHECK_TRANSACTION_URL + request.getId();
|
||||||
|
|
||||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
@@ -458,7 +478,7 @@ public class ComplainServiceImpl implements ComplainService {
|
|||||||
LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
|
LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LOGGER.info("Calling external API: {}", fullUrl);
|
LOGGER.info("[{}] Calling external BBPS API | URL={}", apiName, fullUrl);
|
||||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||||
String responseData = responseMap.get("data");
|
String responseData = responseMap.get("data");
|
||||||
LOGGER.info("checkTxnStatus: {}", responseData);
|
LOGGER.info("checkTxnStatus: {}", responseData);
|
||||||
@@ -483,6 +503,7 @@ public class ComplainServiceImpl implements ComplainService {
|
|||||||
LOGGER.info("Current Complaint ReOpen Status: {}", status);
|
LOGGER.info("Current Complaint ReOpen Status: {}", status);
|
||||||
|
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
|
LOGGER.info("[{}] End Txn Status: {}", apiName, generalResp.getStatus());
|
||||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
@@ -499,14 +520,18 @@ public class ComplainServiceImpl implements ComplainService {
|
|||||||
LOGGER.info("Fetching All Complaint for status Type={} and reqId={} ", request.getStatusType(),
|
LOGGER.info("Fetching All Complaint for status Type={} and reqId={} ", request.getStatusType(),
|
||||||
request.getReqId());
|
request.getReqId());
|
||||||
String apiName = "View_All_Complaint_By_Status_Type";
|
String apiName = "View_All_Complaint_By_Status_Type";
|
||||||
String txnId = helper.generateTxnId(15);
|
|
||||||
String reqId = request.getReqId();
|
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()
|
String fullUrl = complainDataUrl + BBPSConstant.VIEW_ALL_COMPLAINTS_BASE + "?pageNo=" + request.getPageNo()
|
||||||
+ "&pageSize=" + request.getPageSize() + "&statusType=" + request.getStatusType() + "&ticketType="
|
+ "&pageSize=" + request.getPageSize() + "&statusType=" + request.getStatusType() + "&ticketType="
|
||||||
+ request.getTicketType();
|
+ request.getTicketType();
|
||||||
|
|
||||||
helper.validateMerchant(request.getMid());
|
|
||||||
|
|
||||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||||
@@ -518,17 +543,17 @@ public class ComplainServiceImpl implements ComplainService {
|
|||||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||||
String requestJson = helper.convertObjectToJson(request);
|
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);
|
requestJson);
|
||||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET",
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET",
|
||||||
request.getStatusType());
|
request.getStatusType());
|
||||||
LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
|
LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LOGGER.info("Calling external API: {}", fullUrl);
|
LOGGER.info("[{}] Calling external API | URL={}", apiName, fullUrl);
|
||||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||||
String responseData = responseMap.get("data");
|
String responseData = responseMap.get("data");
|
||||||
LOGGER.info("Response: {}", responseData);
|
LOGGER.info("[{}] API Response received", apiName);
|
||||||
|
|
||||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
|
|
||||||
@@ -551,7 +576,7 @@ public class ComplainServiceImpl implements ComplainService {
|
|||||||
LOGGER.info("Current Complaint ReOpen Status: {}", status);
|
LOGGER.info("Current Complaint ReOpen Status: {}", status);
|
||||||
|
|
||||||
String saveComplaint = mapperHelper.saveAllComplaints(responseWrapper, reqId, txnId);
|
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(),
|
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
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.DispositionDetails;
|
||||||
import com.billpaymentservice.bbps.entites.InboundTraceLog;
|
import com.billpaymentservice.bbps.entites.InboundTraceLog;
|
||||||
import com.billpaymentservice.bbps.entites.OutboundTraceLog;
|
import com.billpaymentservice.bbps.entites.OutboundTraceLog;
|
||||||
|
import com.billpaymentservice.bbps.entites.PlanResponses;
|
||||||
import com.billpaymentservice.bbps.exception.CustomException;
|
import com.billpaymentservice.bbps.exception.CustomException;
|
||||||
import com.billpaymentservice.bbps.repository.BharatConnectMasterRepository;
|
import com.billpaymentservice.bbps.repository.BharatConnectMasterRepository;
|
||||||
import com.billpaymentservice.bbps.repository.BillerDataRepository;
|
import com.billpaymentservice.bbps.repository.BillerDataRepository;
|
||||||
@@ -102,30 +103,36 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseModel getMasterData(MasterRequest masterRequest) {
|
public ResponseModel getMasterData(MasterRequest masterRequest) {
|
||||||
LOGGER.info("Fetching Master Data for ReqId={} and MID={}", masterRequest.getReqId(), masterRequest.getMid());
|
|
||||||
String txnID = helper.generateTxnId(15);
|
|
||||||
String apiName = "GetMasterData";
|
String apiName = "GetMasterData";
|
||||||
String requestId = masterRequest.getReqId();
|
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);
|
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);
|
requestJson);
|
||||||
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", requestJson);
|
||||||
try {
|
try {
|
||||||
// Merchant Validation
|
LOGGER.info("[{}] Calling External API | URL={} | Method=GET", apiName, fullUrl);
|
||||||
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);
|
|
||||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||||
String responseData = responseMap.get("data");
|
String responseData = responseMap.get("data");
|
||||||
|
|
||||||
// LOGGER.info("Response Data: {}", responseData);
|
LOGGER.debug("[{}] API Response | reqId={}", apiName, requestId);
|
||||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||||
new TypeReference<Map<String, Object>>() {
|
new TypeReference<Map<String, Object>>() {
|
||||||
@@ -146,7 +153,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||||
|
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
|
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
|
||||||
return responseModel;
|
return responseModel;
|
||||||
|
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
@@ -159,28 +166,31 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseModel getBillerByBillerId(BillerDetailRequest billerDetailRequest) {
|
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 apiName = "Get_Biller_By_BillerId";
|
||||||
String txnID = helper.generateTxnId(15);
|
|
||||||
String apiName = "GetBillerByBillerId";
|
|
||||||
String requestId = billerDetailRequest.getReqId();
|
String requestId = billerDetailRequest.getReqId();
|
||||||
String billerId = billerDetailRequest.getBillerId();
|
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;
|
String fullUrl = masterRegisterUrl + BBPSConstant.BILLER_DATA_FETCH_URL + billerId;
|
||||||
|
// 4. Prepare Logs
|
||||||
String requestJson = helper.convertObjectToJson(billerDetailRequest);
|
String requestJson = helper.convertObjectToJson(billerDetailRequest);
|
||||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, billerDetailRequest.getMid(),
|
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, fullUrl, "GET", requestJson);
|
||||||
"POST", 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 {
|
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,
|
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||||
new TypeReference<Map<String, Object>>() {
|
new TypeReference<Map<String, Object>>() {
|
||||||
});
|
});
|
||||||
@@ -190,6 +200,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||||
String.valueOf(dataMap.get("remarks")));
|
String.valueOf(dataMap.get("remarks")));
|
||||||
}
|
}
|
||||||
|
// Mapping to Model
|
||||||
BillerDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillerDataResponse.class);
|
BillerDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillerDataResponse.class);
|
||||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||||
ModelMapper mapper = new ModelMapper();
|
ModelMapper mapper = new ModelMapper();
|
||||||
@@ -201,6 +212,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
|
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
|
||||||
return responseModel;
|
return responseModel;
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||||
@@ -212,27 +224,26 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
@Override
|
@Override
|
||||||
public ResponseModel getCustomerParamByBillerId(CustomParamRequest customerParamRequest) {
|
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 apiName = "GetCustomerParamByBillerId";
|
||||||
String requestId = customerParamRequest.getReqId();
|
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);
|
String requestJson = helper.convertObjectToJson(customerParamRequest);
|
||||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, customerParamRequest.getMid(),
|
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, customerParamRequest.getMid(),
|
||||||
"POST", requestJson);
|
"GET", requestJson);
|
||||||
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", requestJson);
|
||||||
try {
|
try {
|
||||||
helper.validateMerchant(customerParamRequest.getMid());
|
LOGGER.info("[{}] Calling External API | URL={} | Method=GET", apiName, fullUrl);
|
||||||
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);
|
|
||||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||||
String responseData = responseMap.get("data");
|
String responseData = responseMap.get("data");
|
||||||
LOGGER.info("data is :{}", responseData);
|
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
|
||||||
|
|
||||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
|
|
||||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||||
@@ -258,11 +269,12 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
// Save all to DB
|
// Save all to DB
|
||||||
customParamReposiotory.saveAll(entities);
|
customParamReposiotory.saveAll(entities);
|
||||||
|
LOGGER.info("[{}] Saved {} custom param records to DB", apiName, entities.size());
|
||||||
|
|
||||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
|
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
|
||||||
return responseModel;
|
return responseModel;
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||||
@@ -273,26 +285,28 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseModel getContactMaster(ContactMasterRequest contactMasterRequest) {
|
public ResponseModel getContactMaster(ContactMasterRequest contactMasterRequest) {
|
||||||
LOGGER.info("Fetching Contact Master Request Data " + contactMasterRequest);
|
|
||||||
|
|
||||||
String txnID = helper.generateTxnId(15);
|
String apiName = "Fetch_Master_Data_Category_Wise";
|
||||||
String apiName = "FetchMasterDataCategoryWise";
|
|
||||||
String requestId = contactMasterRequest.getReqId();
|
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);
|
String requestJson = helper.convertObjectToJson(contactMasterRequest);
|
||||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, contactMasterRequest.getMid(),
|
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, contactMasterRequest.getMid(),
|
||||||
"POST", requestJson);
|
"GET", requestJson);
|
||||||
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", requestJson);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
helper.validateMerchant(contactMasterRequest.getMid());
|
LOGGER.info("[{}] Calling External API | URL={} | Method=GET", apiName, fullUrl);
|
||||||
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);
|
|
||||||
|
|
||||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||||
String responseData = responseMap.get("data");
|
String responseData = responseMap.get("data");
|
||||||
LOGGER.info("Response Data: {}", responseData);
|
LOGGER.debug("[{}] External API Response | reqId={} | data={}", apiName, requestId, responseData);
|
||||||
|
|
||||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
|
|
||||||
@@ -313,7 +327,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
String result = mapperHelper.saveContactMasterData(responseWrapper.getContactMasterList(), requestId,
|
String result = mapperHelper.saveContactMasterData(responseWrapper.getContactMasterList(), requestId,
|
||||||
txnID);
|
txnID);
|
||||||
|
|
||||||
LOGGER.info("Result Master Contact Data -:" + result);
|
LOGGER.info("[{}] DB Save Result | reqId={} | result={}", apiName, requestId, result);
|
||||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||||
|
|
||||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||||
@@ -321,6 +335,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
|
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
|
|
||||||
|
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
|
||||||
return responseModel;
|
return responseModel;
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||||
@@ -331,26 +346,33 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseModel fetchMasterDataCategoryWise(MasterCategoryRequest masterRequest) {
|
public ResponseModel fetchMasterDataCategoryWise(MasterCategoryRequest masterRequest) {
|
||||||
LOGGER.info("Fetching Master Data CategoryResponseList-wise " + masterRequest);
|
|
||||||
|
|
||||||
String txnID = helper.generateTxnId(15);
|
|
||||||
String apiName = "FetchMasterDataCategoryWise";
|
String apiName = "FetchMasterDataCategoryWise";
|
||||||
String requestId = masterRequest.getReqId();
|
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);
|
String requestJson = helper.convertObjectToJson(masterRequest);
|
||||||
|
|
||||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, masterRequest.getMid(), "POST",
|
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, masterRequest.getMid(), "POST",
|
||||||
requestJson);
|
requestJson);
|
||||||
|
|
||||||
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", requestJson);
|
||||||
|
|
||||||
try {
|
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);
|
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||||
String responseData = responseMap.get("data");
|
String responseData = responseMap.get("data");
|
||||||
// LOGGER.info("Response Data: {}", responseData);
|
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
|
||||||
|
|
||||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
|
|
||||||
@@ -370,6 +392,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
BillerResponse responseWrapper = objectMapper.convertValue(dataMap, BillerResponse.class);
|
BillerResponse responseWrapper = objectMapper.convertValue(dataMap, BillerResponse.class);
|
||||||
List<BillerCategoryWise> savedEntities = mapperHelper.mapAndSaveAll(responseWrapper.getBillerResp(),
|
List<BillerCategoryWise> savedEntities = mapperHelper.mapAndSaveAll(responseWrapper.getBillerResp(),
|
||||||
requestId, txnID);
|
requestId, txnID);
|
||||||
|
LOGGER.info("[{}] Saved {} records to DB | reqId={}", apiName, savedEntities.size(), requestId);
|
||||||
|
|
||||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||||
|
|
||||||
@@ -377,7 +400,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||||
|
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
|
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
|
||||||
return responseModel;
|
return responseModel;
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||||
@@ -388,24 +411,26 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseModel getDispositionDetails(DispositionRequest dispositionDetailRequest) {
|
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 apiName = "GetDispositionDetails";
|
||||||
String requestId = dispositionDetailRequest.getReqId();
|
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,
|
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
|
||||||
dispositionDetailRequest.getMid(), "GET", "N/A");
|
dispositionDetailRequest.getMid(), "GET", "N/A");
|
||||||
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET",
|
||||||
String fullUrl = masterRegisterUrl + BBPSConstant.DISPOSTION_URL;
|
dispositionDetailRequest.getMid());
|
||||||
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 {
|
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();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
@@ -421,15 +446,13 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DispositionResponse responseWrapper = objectMapper.convertValue(dataMap, DispositionResponse.class);
|
DispositionResponse responseWrapper = objectMapper.convertValue(dataMap, DispositionResponse.class);
|
||||||
System.out.println(responseWrapper);
|
|
||||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||||
ModelMapper mapper = new ModelMapper();
|
ModelMapper mapper = new ModelMapper();
|
||||||
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||||
List<DispositionDetails> entities = responseWrapper.getDispositionsList().stream()
|
List<DispositionDetails> entities = responseWrapper.getDispositionsList().stream()
|
||||||
.map(dto -> mapper.map(dto, DispositionDetails.class)).collect(Collectors.toList());
|
.map(dto -> mapper.map(dto, DispositionDetails.class)).collect(Collectors.toList());
|
||||||
|
|
||||||
System.out.println(entities);
|
LOGGER.info("[{}] Dispositions Received: {}", apiName, entities.size());
|
||||||
|
|
||||||
if (entities != null) {
|
if (entities != null) {
|
||||||
dispositionRepository.saveAll(entities);
|
dispositionRepository.saveAll(entities);
|
||||||
} else {
|
} else {
|
||||||
@@ -441,6 +464,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
|
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
|
|
||||||
|
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
|
||||||
return responseModel;
|
return responseModel;
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||||
@@ -452,22 +476,27 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseModel fetchCustomerParamGroup(BillerDetailRequest requestModel) {
|
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 apiName = "FetchCustomerParamGroup";
|
||||||
String requestId = requestModel.getReqId();
|
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));
|
helper.convertObjectToJson(requestModel));
|
||||||
|
|
||||||
try {
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
||||||
helper.validateMerchant(requestModel.getMid());
|
|
||||||
|
|
||||||
String fullUrl = masterRegisterUrl + BBPSConstant.CUSTOMER_PARAM_GROUP + requestModel.getBillerId();
|
try {
|
||||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
LOGGER.info("[{}] Calling External API | URL={} | Method=GET", apiName, fullUrl);
|
||||||
LOGGER.info("Calling external API: {}", fullUrl);
|
|
||||||
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
|
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
|
||||||
String responseData = apiResponse.get("data").toString();
|
String responseData = apiResponse.get("data").toString();
|
||||||
|
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
|
||||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
|
|
||||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||||
@@ -489,10 +518,13 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
CustomerParamGroupsDTO responseDTO = mapperHelper
|
CustomerParamGroupsDTO responseDTO = mapperHelper
|
||||||
.saveCustomerParamGroups(responseWrapper.getCustomerParamGroupResp(), requestId, txnID);
|
.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(),
|
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||||
|
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
|
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
|
||||||
|
|
||||||
return responseModel;
|
return responseModel;
|
||||||
|
|
||||||
@@ -507,24 +539,29 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
@Override
|
@Override
|
||||||
public ResponseModel fetchAllMasterAmountOption(BillerDetailRequest requestModel) {
|
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 apiName = "FetchAllMasterAmountOption";
|
||||||
String requestId = requestModel.getReqId();
|
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",
|
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "POST",
|
||||||
helper.convertObjectToJson(requestModel));
|
helper.convertObjectToJson(requestModel));
|
||||||
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
||||||
try {
|
try {
|
||||||
helper.validateMerchant(requestModel.getMid());
|
|
||||||
|
|
||||||
String fullUrl = masterRegisterUrl + BBPSConstant.AMOUNT_OPTIONS + requestModel.getBillerId();
|
LOGGER.info("[{}] Calling External API | URL={} | Method=GET", apiName, fullUrl);
|
||||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
|
||||||
LOGGER.info("Calling external API: {}", fullUrl);
|
|
||||||
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
|
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
|
||||||
LOGGER.info("Response" + apiResponse);
|
LOGGER.info("Response" + apiResponse);
|
||||||
String responseData = apiResponse.get("data").toString();
|
String responseData = apiResponse.get("data").toString();
|
||||||
|
|
||||||
|
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
|
||||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
|
|
||||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||||
@@ -543,6 +580,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
|
|
||||||
String saveAmountOptionsResponse = mapperHelper.saveAmountOptionsResponse(responseWrapper, requestId,
|
String saveAmountOptionsResponse = mapperHelper.saveAmountOptionsResponse(responseWrapper, requestId,
|
||||||
txnID);
|
txnID);
|
||||||
|
LOGGER.info("[{}] Save Result | reqId={} | result={}", apiName, requestId, saveAmountOptionsResponse);
|
||||||
|
|
||||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||||
|
|
||||||
@@ -551,6 +589,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
|
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
|
|
||||||
|
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
|
||||||
return responseModel;
|
return responseModel;
|
||||||
|
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
@@ -563,19 +602,21 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseModel fetchPlanCategorie(BillerDetailRequest requestModel) {
|
public ResponseModel fetchPlanCategorie(BillerDetailRequest requestModel) {
|
||||||
LOGGER.info("Fetching Plan Categories for ReqId={} and MID={}", requestModel.getReqId(), requestModel.getMid());
|
|
||||||
String txnID = helper.generateTxnId(15);
|
|
||||||
String apiName = "FetchPlanCategorie";
|
String apiName = "FetchPlanCategorie";
|
||||||
String requestId = requestModel.getReqId();
|
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));
|
helper.convertObjectToJson(requestModel));
|
||||||
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
||||||
try {
|
try {
|
||||||
helper.validateMerchant(requestModel.getMid());
|
LOGGER.info("[{}] Calling External API | URL={} | Method=GET", apiName, fullUrl);
|
||||||
|
|
||||||
String fullUrl = masterRegisterUrl + BBPSConstant.PLAN_CATEGORIES + requestModel.getBillerId();
|
|
||||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
|
||||||
LOGGER.info("Calling external API: {}", fullUrl);
|
|
||||||
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
|
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
|
||||||
LOGGER.info("Response" + apiResponse);
|
LOGGER.info("Response" + apiResponse);
|
||||||
String responseData = apiResponse.get("data").toString();
|
String responseData = apiResponse.get("data").toString();
|
||||||
@@ -596,14 +637,17 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
|
|
||||||
PlaneCategoriesResponse responseWrapper = objectMapper.convertValue(dataMap, PlaneCategoriesResponse.class);
|
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();
|
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||||
|
|
||||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||||
|
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
|
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
|
||||||
return responseModel;
|
return responseModel;
|
||||||
|
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
@@ -616,24 +660,27 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseModel fetchInitiatingChannel(BillerDetailRequest requestModel) {
|
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 apiName = "FetchInitiatingChannel";
|
||||||
String requestId = requestModel.getReqId();
|
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));
|
helper.convertObjectToJson(requestModel));
|
||||||
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", mid);
|
||||||
|
|
||||||
try {
|
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);
|
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
|
||||||
LOGGER.info("Response" + apiResponse);
|
|
||||||
String responseData = apiResponse.get("data").toString();
|
String responseData = apiResponse.get("data").toString();
|
||||||
|
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
|
||||||
|
|
||||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
|
|
||||||
@@ -656,6 +703,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||||
|
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
|
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
|
||||||
|
|
||||||
return responseModel;
|
return responseModel;
|
||||||
|
|
||||||
@@ -669,13 +717,14 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
|
|
||||||
public ResponseModel fetchPlanByCategories(PlanRequest requestModel) {
|
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 apiName = "FetchPlanByCategories";
|
||||||
String requestId = requestModel.getReqId();
|
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,
|
String url = String.format("%s%s?billerId=%s%s%s%s&page=%d&pagesize=%d", masterRegisterUrl,
|
||||||
BBPSConstant.PLANS_URL, requestModel.getBillerId(),
|
BBPSConstant.PLANS_URL, requestModel.getBillerId(),
|
||||||
@@ -688,13 +737,14 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
|
|
||||||
// Convert request to JSON and create inbound & outbound logs
|
// Convert request to JSON and create inbound & outbound logs
|
||||||
String requestJson = helper.convertObjectToJson(requestModel);
|
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);
|
requestJson);
|
||||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, "GET", null);
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, "GET", null);
|
||||||
try {
|
try {
|
||||||
|
LOGGER.info("[{}] Calling Master API | URL={} | Method=GET", apiName, url);
|
||||||
Map<String, String> apiResponse = httpService.getRequest(url);
|
Map<String, String> apiResponse = httpService.getRequest(url);
|
||||||
String responseData = apiResponse.get("data");
|
String responseData = apiResponse.get("data");
|
||||||
LOGGER.info("Response Data: {}", responseData);
|
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
|
||||||
|
|
||||||
// Update outbound log with response
|
// Update outbound log with response
|
||||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
@@ -715,11 +765,14 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
PlanResponse responseWrapper = objectMapper.convertValue(dataMap, PlanResponse.class);
|
PlanResponse responseWrapper = objectMapper.convertValue(dataMap, PlanResponse.class);
|
||||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
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(),
|
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||||
|
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
|
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
|
||||||
return responseModel;
|
return responseModel;
|
||||||
|
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
@@ -731,24 +784,27 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseModel getTicketDispositions(DispositionRequest dispositionDetailRequest) {
|
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 apiName = "GetTicketDispositionDetails";
|
||||||
String requestId = dispositionDetailRequest.getReqId();
|
String requestId = dispositionDetailRequest.getReqId();
|
||||||
|
String mid = dispositionDetailRequest.getMid();
|
||||||
|
|
||||||
|
LOGGER.info("[{}] START | reqId={} | mid={}", apiName, requestId, mid);
|
||||||
|
|
||||||
helper.validateMerchant(dispositionDetailRequest.getMid());
|
helper.validateMerchant(dispositionDetailRequest.getMid());
|
||||||
|
String txnID = helper.generateTxnId(15);
|
||||||
|
String fullUrl = masterRegisterUrl + BBPSConstant.TICKET_DISPOSTION_URL;
|
||||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
|
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
|
||||||
dispositionDetailRequest.getMid(), "GET", "N/A");
|
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 {
|
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();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
@@ -765,16 +821,18 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
|
|
||||||
TicketDispositionResponse responseWrapper = objectMapper.convertValue(dataMap,
|
TicketDispositionResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||||
TicketDispositionResponse.class);
|
TicketDispositionResponse.class);
|
||||||
System.out.println(responseWrapper);
|
|
||||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||||
|
|
||||||
ModelMapper mapper = new ModelMapper();
|
ModelMapper mapper = new ModelMapper();
|
||||||
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||||
mapperHelper.saveTicketDisoptionDetails(responseWrapper.getDispositionsList(), requestId, txnID);
|
mapperHelper.saveTicketDisoptionDetails(responseWrapper.getDispositionsList(), requestId, txnID);
|
||||||
|
|
||||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||||
|
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
|
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
|
||||||
return responseModel;
|
return responseModel;
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||||
|
|||||||
@@ -79,445 +79,453 @@ public class PaymentServiceImpl implements PaymentService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseModel initiatePayment(BillPaymentRequest billPaymentRequest) {
|
public ResponseModel initiatePayment(BillPaymentRequest billPaymentRequest) {
|
||||||
String apiName = "InitiatePayment";
|
String apiName = "InitiatePayment";
|
||||||
String txnId = helper.generateTxnId(15);
|
String requestId = billPaymentRequest.getReqId();
|
||||||
String requestId = billPaymentRequest.getReqId();
|
String mid = billPaymentRequest.getMid();
|
||||||
String url = paymentUrl + BBPSConstant.PAYMENT_URL;
|
LOGGER.info("[{}] START | reqId={} | mid={}", apiName, requestId, mid);
|
||||||
billPaymentRequest.setClientReqId(txnId);
|
helper.validateMerchant(mid);
|
||||||
LOGGER.info("Initiating payment for reqId={} and txnId={}", requestId, txnId);
|
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");
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||||
headers.set("agentId", headersData.getAgentId());
|
headers.set("agentId", headersData.getAgentId());
|
||||||
headers.set("tenantId", headersData.getTenantId());
|
headers.set("tenantId", headersData.getTenantId());
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||||
BillPaymentForwardRequest forwardReq =
|
BillPaymentForwardRequest forwardReq = helper.billPaymentForwardRequest(billPaymentRequest);
|
||||||
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);
|
try {
|
||||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, "POST",forwardjson);
|
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 {
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
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);
|
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()) {
|
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||||
helper.updateInboundLogFailure(inboundLog, "Empty response from BBPS", "FAILED");
|
new TypeReference<Map<String, Object>>() {
|
||||||
LOGGER.warn("Empty response received from BBPS for txnId={}", txnId);
|
});
|
||||||
throw new CustomException("Empty response from BBPS server");
|
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>>() {});
|
BillPaymentResponse billPaymentResponse = objectMapper.convertValue(dataMap, BillPaymentResponse.class);
|
||||||
if (!dataMap.containsKey("genericResponse")) {
|
GeneralResp generalResponse = billPaymentResponse.getGenericResponse();
|
||||||
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);
|
ModelMapper mapper = new ModelMapper();
|
||||||
GeneralResp generalResponse = billPaymentResponse.getGenericResponse();
|
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();
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResponse.getStatus());
|
||||||
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
PaymentInitiate paymentInitiate = new PaymentInitiate();
|
||||||
BillPayment entity = mapper.map(billPaymentResponse, BillPayment.class);
|
paymentInitiate.setTxnId(txnId);
|
||||||
paymentRepository.save(entity);
|
paymentInitiate.setReqId(requestId);
|
||||||
LOGGER.info("BillPayment entity saved successfully for txnId={}", txnId);
|
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());
|
LOGGER.info("[{}] Checking Transaction Status for bankTxnId={}", apiName, billPaymentResponse.getTxnId());
|
||||||
PaymentInitiate paymentInitiate = new PaymentInitiate();
|
TransactionStatusRequest transactionStatusRequest = new TransactionStatusRequest();
|
||||||
paymentInitiate.setTxnId(txnId);
|
transactionStatusRequest.setTxnId(billPaymentResponse.getTxnId());
|
||||||
paymentInitiate.setReqId(requestId);
|
transactionStatusRequest.setReqId(requestId);
|
||||||
paymentInitiate.setBankTxnId(billPaymentResponse.getTxnId());
|
|
||||||
paymentInitiate.setStatus(billPaymentResponse.getStatus());
|
|
||||||
paymentIntiateRepository.save(paymentInitiate);
|
|
||||||
LOGGER.info("PaymentInitiate entry saved successfully for txnId={}", txnId);
|
|
||||||
|
|
||||||
TransactionStatusRequest transactionStatusRequest = new TransactionStatusRequest();
|
try {
|
||||||
transactionStatusRequest.setTxnId(billPaymentResponse.getTxnId());
|
Thread.sleep(9000);
|
||||||
transactionStatusRequest.setReqId(requestId);
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
try {
|
LOGGER.warn("Thread interrupted during payment delay: {}", e.getMessage());
|
||||||
Thread.sleep(9000);
|
}
|
||||||
} catch (InterruptedException e) {
|
LOGGER.info("Checking transaction status for txnId={}", billPaymentResponse.getTxnId());
|
||||||
Thread.currentThread().interrupt();
|
return checkTrasactionStatus(transactionStatusRequest, inboundLog);
|
||||||
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) {
|
} catch (JsonProcessingException e) {
|
||||||
LOGGER.error("JSON Parsing Error in initiatePayment: {}", e.getMessage(), e);
|
LOGGER.error("JSON Parsing Error in initiatePayment: {}", 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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest, InboundTraceLog inboundLog) {
|
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest,
|
||||||
String apiName = "CheckTransactionStatus";
|
InboundTraceLog inboundLog) {
|
||||||
String txnId = helper.generateTxnId(15);
|
String apiName = "CheckTransactionStatus";
|
||||||
String requestId = transactionStatusRequest.getReqId();
|
String txnId = helper.generateTxnId(15);
|
||||||
|
String requestId = transactionStatusRequest.getReqId();
|
||||||
|
|
||||||
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
|
|
||||||
|
|
||||||
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");
|
LOGGER.info("Checking transaction status (internal) for txnId={} and reqId={}",
|
||||||
HttpHeaders headers = new HttpHeaders();
|
transactionStatusRequest.getTxnId(), requestId);
|
||||||
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();
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, "GET", null);
|
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);
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
String responseData = responseMap.get("data");
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, "GET", null);
|
||||||
LOGGER.info("Transaction status response: {}", responseData);
|
|
||||||
|
|
||||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||||
|
String responseData = responseMap.get("data");
|
||||||
|
LOGGER.info("Transaction status response: {}", responseData);
|
||||||
|
|
||||||
try {
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
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"))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
|
try {
|
||||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||||
LOGGER.info("Transaction status received: {}", generalResp.getStatus());
|
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();
|
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||||
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
TransactionStatusResponse.class);
|
||||||
TransactionMaster transactionMaster = mapper.map(responseWrapper.getTransactionDAO(), TransactionMaster.class);
|
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||||
transactionMaster.setTxnId(txnId);
|
LOGGER.info("Transaction status received: {}", generalResp.getStatus());
|
||||||
transactionMaster.setReqId(transactionStatusRequest.getReqId());
|
|
||||||
EntityRelationshipUtil.linkTransactionMasterRelationships(transactionMaster);
|
|
||||||
transactionMasterRepository.save(transactionMaster);
|
|
||||||
LOGGER.info("TransactionMaster saved successfully for txnId={}", txnId);
|
|
||||||
|
|
||||||
AgentFundTransfer agentFundTransfer = mapper.map(responseWrapper.getAgentFundTransfer(), AgentFundTransfer.class);
|
ModelMapper mapper = new ModelMapper();
|
||||||
agentFundTransfer.setTxnId(txnId);
|
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||||
agentFundTransfer.setReqId(transactionStatusRequest.getReqId());
|
TransactionMaster transactionMaster = mapper.map(responseWrapper.getTransactionDAO(),
|
||||||
agentFundTransfer.setTransactionMasterId(transactionMaster.getBankTxnId());
|
TransactionMaster.class);
|
||||||
agentFundTransferRepository.save(agentFundTransfer);
|
transactionMaster.setTxnId(txnId);
|
||||||
LOGGER.info("AgentFundTransfer entry saved successfully for txnId={}", txnId);
|
transactionMaster.setReqId(transactionStatusRequest.getReqId());
|
||||||
|
EntityRelationshipUtil.linkTransactionMasterRelationships(transactionMaster);
|
||||||
|
transactionMasterRepository.save(transactionMaster);
|
||||||
|
LOGGER.info("TransactionMaster saved successfully for txnId={}", txnId);
|
||||||
|
|
||||||
ResponseModel responseModel = new ResponseModel(
|
AgentFundTransfer agentFundTransfer = mapper.map(responseWrapper.getAgentFundTransfer(),
|
||||||
generalResp.getMessage(),
|
AgentFundTransfer.class);
|
||||||
generalResp.getStatus(),
|
agentFundTransfer.setTxnId(txnId);
|
||||||
Integer.parseInt(generalResp.getStatusCode()),
|
agentFundTransfer.setReqId(transactionStatusRequest.getReqId());
|
||||||
responseWrapper
|
agentFundTransfer.setTransactionMasterId(transactionMaster.getBankTxnId());
|
||||||
);
|
agentFundTransferRepository.save(agentFundTransfer);
|
||||||
|
LOGGER.info("AgentFundTransfer entry saved successfully for txnId={}", txnId);
|
||||||
|
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||||
return responseModel;
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||||
|
|
||||||
} catch (JsonProcessingException e) {
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
LOGGER.error("Error parsing transaction status JSON: {}", e.getMessage(), e);
|
return responseModel;
|
||||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
|
||||||
throw new CustomException("Invalid JSON received from API");
|
} 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
|
@Override
|
||||||
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest) {
|
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest) {
|
||||||
helper.validateMerchant(transactionStatusRequest.getMid());
|
helper.validateMerchant(transactionStatusRequest.getMid());
|
||||||
String txnID = helper.generateTxnId(15);
|
|
||||||
String apiName = "checkTrasactionStatus";
|
String apiName = "checkTrasactionStatus";
|
||||||
String requestId = transactionStatusRequest.getReqId();
|
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 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");
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||||
headers.set("agentId", headersData.getAgentId());
|
headers.set("agentId", headersData.getAgentId());
|
||||||
headers.set("tenantId", headersData.getTenantId());
|
headers.set("tenantId", headersData.getTenantId());
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, transactionStatusRequest.getMid(), "POST", requestJson);
|
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
|
||||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, "GET", null);
|
transactionStatusRequest.getMid(), "POST", requestJson);
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, "GET", null);
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||||
String responseData = responseMap.get("data");
|
String responseData = responseMap.get("data");
|
||||||
LOGGER.info("Transaction status response data: {}", responseData);
|
LOGGER.info("Transaction status response data: {}", responseData);
|
||||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
|
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||||
if (!dataMap.containsKey("generalResp")) {
|
new TypeReference<Map<String, Object>>() {
|
||||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
});
|
||||||
LOGGER.warn("Invalid transaction status response for txnId={} from BBPS", transactionStatusRequest.getTxnId());
|
if (!dataMap.containsKey("generalResp")) {
|
||||||
throw new CustomException(
|
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
||||||
String.valueOf(dataMap.get("message")),
|
LOGGER.warn("Invalid transaction status response for txnId={} from BBPS",
|
||||||
String.valueOf(dataMap.get("status")),
|
transactionStatusRequest.getTxnId());
|
||||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||||
String.valueOf(dataMap.get("remarks"))
|
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||||
);
|
String.valueOf(dataMap.get("remarks")));
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
|
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
TransactionStatusResponse.class);
|
||||||
|
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||||
|
|
||||||
String status = generalResp.getStatus();
|
String status = generalResp.getStatus();
|
||||||
LOGGER.info("Current transaction status: {}", status);
|
LOGGER.info("Current transaction status: {}", status);
|
||||||
|
|
||||||
ResponseModel responseModel = new ResponseModel(
|
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||||
generalResp.getMessage(),
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||||
generalResp.getStatus(),
|
|
||||||
Integer.parseInt(generalResp.getStatusCode()),
|
|
||||||
responseWrapper
|
|
||||||
);
|
|
||||||
|
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
return responseModel;
|
return responseModel;
|
||||||
|
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage(), e);
|
LOGGER.error("Error parsing responseData JSON: {}", 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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@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);
|
helper.validateMerchant(transactionStatusRequest.getMid());
|
||||||
String apiName = "checkTrasactionStatusbyClientReqId";
|
String txnID = helper.generateTxnId(15);
|
||||||
String requestId = transactionStatusRequest.getReqId();
|
String requestJson = helper.convertObjectToJson(transactionStatusRequest);
|
||||||
String clientReqId = transactionStatusRequest.getClientReqId();
|
|
||||||
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
|
// Fetch Txn from DB
|
||||||
Optional<PaymentInitiate> paymentInitiate = paymentIntiateRepository.findByReqId(clientReqId);
|
Optional<PaymentInitiate> paymentInitiate = paymentIntiateRepository.findByReqId(clientReqId);
|
||||||
if (paymentInitiate.isEmpty()) {
|
if (paymentInitiate.isEmpty()) {
|
||||||
throw new CustomException("No Transaction Found for given Client Req Id");
|
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
|
LOGGER.info("[{}] BBPS URL={}", apiName, url);
|
||||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
// Prepare headers
|
||||||
HttpHeaders headers = new HttpHeaders();
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("agentId", headersData.getAgentId());
|
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||||
headers.set("tenantId", headersData.getTenantId());
|
headers.set("agentId", headersData.getAgentId());
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
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
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, "GET", null);
|
||||||
InboundTraceLog inboundLog = helper.createInboundLog(
|
|
||||||
requestId, txnID, apiName, transactionStatusRequest.getMid(), "POST", requestJson);
|
|
||||||
|
|
||||||
OutboundTraceLog outboundLog = helper.createOutboundLog(
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
txnID, requestId, apiName, url, "GET", null);
|
|
||||||
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
try {
|
||||||
|
LOGGER.info("Calling BBPS Transaction Status API URL={}", url);
|
||||||
|
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||||
|
|
||||||
try {
|
String responseData = responseMap.get("data");
|
||||||
LOGGER.info("Calling BBPS Transaction Status API URL={}", url);
|
LOGGER.debug("[{}] Raw Response | reqId={} | data={}", apiName, requestId, responseData);
|
||||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
|
||||||
|
|
||||||
String responseData = responseMap.get("data");
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
LOGGER.info("Transaction Status Response: {}", responseData);
|
|
||||||
|
|
||||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
// Parse response
|
||||||
|
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||||
|
new TypeReference<Map<String, Object>>() {
|
||||||
|
});
|
||||||
|
|
||||||
// Parse response
|
// Validate response
|
||||||
Map<String, Object> dataMap = objectMapper.readValue(
|
if (!dataMap.containsKey("generalResp")) {
|
||||||
responseData, new TypeReference<Map<String, Object>>() {});
|
LOGGER.warn("[{}] INVALID RESPONSE | reqId={} | response={}", apiName, requestId, responseData);
|
||||||
|
|
||||||
// Validate response
|
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||||
if (!dataMap.containsKey("generalResp")) {
|
|
||||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
|
||||||
|
|
||||||
LOGGER.warn("Invalid transaction status response for clientReqId={} | Response={}",
|
LOGGER.warn("Invalid transaction status response for clientReqId={} | Response={}", clientReqId,
|
||||||
clientReqId, responseData);
|
responseData);
|
||||||
|
|
||||||
throw new CustomException(
|
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||||
String.valueOf(dataMap.get("message")),
|
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||||
String.valueOf(dataMap.get("status")),
|
String.valueOf(dataMap.get("remarks")));
|
||||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
}
|
||||||
String.valueOf(dataMap.get("remarks"))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert into proper DTO
|
// Convert into proper DTO
|
||||||
TransactionStatusResponse responseWrapper =
|
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||||
objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
|
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(
|
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||||
generalResp.getMessage(),
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||||
generalResp.getStatus(),
|
|
||||||
Integer.parseInt(generalResp.getStatusCode()),
|
|
||||||
responseWrapper
|
|
||||||
);
|
|
||||||
|
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
LOGGER.error("Error parsing JSON in transaction status API: {}", e.getMessage(), 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
|
* PollBack logic for the fetchTxnByTxnId API
|
||||||
* billFetchByBillIdRequest) {
|
*
|
||||||
*
|
* @Override public ResponseModel fetchTxnByTxnId(BillFetchByBillIdRequest
|
||||||
* String billId = billFetchByBillIdRequest.getBillId(); String fullUrl =
|
* billFetchByBillIdRequest) {
|
||||||
* agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID+billId;
|
*
|
||||||
* System.out.print(fullUrl);
|
* String billId = billFetchByBillIdRequest.getBillId(); String fullUrl =
|
||||||
*
|
* agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID+billId;
|
||||||
* BeneficiaryDetails
|
* System.out.print(fullUrl);
|
||||||
* headersData=beneficiaryDetailsRepository.findByOrgId("ORG001");
|
*
|
||||||
*
|
* BeneficiaryDetails
|
||||||
* HttpHeaders headers = new HttpHeaders();
|
* headersData=beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
* headers.set("x-digiledge-key",headersData.getXDigiledgeKey());
|
*
|
||||||
* headers.set("agentId", headersData.getAgentId()); headers.set("tenantId",
|
* HttpHeaders headers = new HttpHeaders();
|
||||||
* headersData.getTenantId());
|
* headers.set("x-digiledge-key",headersData.getXDigiledgeKey());
|
||||||
* headers.setContentType(MediaType.APPLICATION_JSON);
|
* headers.set("agentId", headersData.getAgentId()); headers.set("tenantId",
|
||||||
*
|
* headersData.getTenantId());
|
||||||
* Map<String, String> responseMap = httpService.getRequest(fullUrl,headers);
|
* headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
* String responseData = responseMap.get("data"); log.info("data is :{}",
|
*
|
||||||
* responseData);
|
* 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
|
* ObjectMapper objectMapper = new ObjectMapper();
|
||||||
* TypeReference<Map<String, Object>>() { }); if
|
*
|
||||||
* (!dataMap.containsKey("genericResponse")) { throw new
|
* try { Map<String, Object> dataMap = objectMapper.readValue(responseData, new
|
||||||
* CustomException(String.valueOf(dataMap.get("message")), // message
|
* TypeReference<Map<String, Object>>() { }); if
|
||||||
* String.valueOf(dataMap.get("status")), // status
|
* (!dataMap.containsKey("genericResponse")) { throw new
|
||||||
* Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode
|
* CustomException(String.valueOf(dataMap.get("message")), // message
|
||||||
* (int) String.valueOf(dataMap.get("remarks")) ); }
|
* String.valueOf(dataMap.get("status")), // status
|
||||||
*
|
* Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode
|
||||||
* BillDataResponse responseWrapper = objectMapper.convertValue(dataMap,
|
* (int) String.valueOf(dataMap.get("remarks")) ); }
|
||||||
* BillDataResponse.class);
|
*
|
||||||
*
|
* BillDataResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||||
* GeneralResp generalResp = responseWrapper.getGenericResponse();
|
* BillDataResponse.class);
|
||||||
*
|
*
|
||||||
* ResponseModel responseModel=new ResponseModel( generalResp.getMessage(),
|
* GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||||
* generalResp.getStatus(), Integer.parseInt(generalResp.getStatusCode()),
|
*
|
||||||
* responseWrapper);
|
* ResponseModel responseModel=new ResponseModel( generalResp.getMessage(),
|
||||||
*
|
* generalResp.getStatus(), Integer.parseInt(generalResp.getStatusCode()),
|
||||||
* return responseModel;
|
* responseWrapper);
|
||||||
*
|
*
|
||||||
* } catch (JsonProcessingException e) {
|
* return responseModel;
|
||||||
* LOGGER.error("Error parsing responseData JSON: {}", e.getMessage()); throw
|
*
|
||||||
* new CustomException("Invalid JSON received from API"); }
|
* } catch (JsonProcessingException e) {
|
||||||
*
|
* LOGGER.error("Error parsing responseData JSON: {}", e.getMessage()); throw
|
||||||
* }
|
* new CustomException("Invalid JSON received from API"); }
|
||||||
*/
|
*
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* public ResponseModel checkTrasactionStatus(TransactionStatusRequest
|
* public ResponseModel checkTrasactionStatus(TransactionStatusRequest
|
||||||
* transactionStatusRequest,InboundTraceLog inboundLog) { String apiName =
|
* transactionStatusRequest,InboundTraceLog inboundLog) { String apiName =
|
||||||
* "CheckTransactionStatus"; String txnId = helper.generateTxnId(15); //our
|
* "CheckTransactionStatus"; String txnId = helper.generateTxnId(15); //our
|
||||||
* genrated txnId String requestId = transactionStatusRequest.getReqId(); String
|
* genrated txnId String requestId = transactionStatusRequest.getReqId(); String
|
||||||
* url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL +
|
* url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL +
|
||||||
* transactionStatusRequest.getTxnId(); ;
|
* transactionStatusRequest.getTxnId(); ;
|
||||||
*
|
*
|
||||||
* BharatConnectMaster headersData =
|
* BharatConnectMaster headersData =
|
||||||
* beneficiaryDetailsRepository.findByOrgId("ORG001"); HttpHeaders headers = new
|
* beneficiaryDetailsRepository.findByOrgId("ORG001"); HttpHeaders headers = new
|
||||||
* HttpHeaders(); headers.set("x-digiledge-key",
|
* HttpHeaders(); headers.set("x-digiledge-key",
|
||||||
* headersData.getXDigiledgeKey()); headers.set("agentId",
|
* headersData.getXDigiledgeKey()); headers.set("agentId",
|
||||||
* headersData.getAgentId()); headers.set("tenantId",
|
* headersData.getAgentId()); headers.set("tenantId",
|
||||||
* headersData.getTenantId());
|
* headersData.getTenantId());
|
||||||
* headers.setContentType(MediaType.APPLICATION_JSON); ObjectMapper objectMapper
|
* headers.setContentType(MediaType.APPLICATION_JSON); ObjectMapper objectMapper
|
||||||
* = new ObjectMapper();
|
* = new ObjectMapper();
|
||||||
*
|
*
|
||||||
* OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId,
|
* OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId,
|
||||||
* apiName, url, "GET", null);
|
* apiName, url, "GET", null);
|
||||||
*
|
*
|
||||||
* long startTime = System.currentTimeMillis(); long maxWaitTimeMs = 40000; long
|
* long startTime = System.currentTimeMillis(); long maxWaitTimeMs = 40000; long
|
||||||
* intervalMs = 5000;
|
* intervalMs = 5000;
|
||||||
*
|
*
|
||||||
* while (true) { Map<String, String> responseMap = httpService.getRequest(url,
|
* while (true) { Map<String, String> responseMap = httpService.getRequest(url,
|
||||||
* headers); String responseData = responseMap.get("data");
|
* headers); String responseData = responseMap.get("data");
|
||||||
* LOGGER.info("Transaction status response: {}", responseData);
|
* LOGGER.info("Transaction status response: {}", responseData);
|
||||||
*
|
*
|
||||||
* helper.updateOutboundLogResponse(outboundLog, responseData);
|
* helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
*
|
*
|
||||||
* try { Map<String, Object> dataMap = objectMapper.readValue(responseData, new
|
* try { Map<String, Object> dataMap = objectMapper.readValue(responseData, new
|
||||||
* TypeReference<Map<String, Object>>() {});
|
* TypeReference<Map<String, Object>>() {});
|
||||||
*
|
*
|
||||||
* if (!dataMap.containsKey("generalResp")) {
|
* if (!dataMap.containsKey("generalResp")) {
|
||||||
* helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
* helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||||
* throw new CustomException( String.valueOf(dataMap.get("message")),
|
* throw new CustomException( String.valueOf(dataMap.get("message")),
|
||||||
* String.valueOf(dataMap.get("status")),
|
* String.valueOf(dataMap.get("status")),
|
||||||
* Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
* Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||||
* String.valueOf(dataMap.get("remarks")) ); }
|
* String.valueOf(dataMap.get("remarks")) ); }
|
||||||
*
|
*
|
||||||
* TransactionStatusResponse responseWrapper =
|
* TransactionStatusResponse responseWrapper =
|
||||||
* objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
|
* objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
|
||||||
* GeneralResp generalResp = responseWrapper.getGeneralResp();
|
* GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||||
*
|
*
|
||||||
* String status = generalResp.getStatus();
|
* String status = generalResp.getStatus();
|
||||||
* LOGGER.info("Current transaction status: {}", status);
|
* LOGGER.info("Current transaction status: {}", status);
|
||||||
*
|
*
|
||||||
* if ("INPROGRESS".equalsIgnoreCase(status)) { if (System.currentTimeMillis() -
|
* if ("INPROGRESS".equalsIgnoreCase(status)) { if (System.currentTimeMillis() -
|
||||||
* startTime > maxWaitTimeMs) { helper.updateInboundLogFailure(inboundLog,
|
* startTime > maxWaitTimeMs) { helper.updateInboundLogFailure(inboundLog,
|
||||||
* "Timeout after 40 seconds", "FAILED"); throw new
|
* "Timeout after 40 seconds", "FAILED"); throw new
|
||||||
* CustomException("Timeout waiting for transaction completion", "FAILED", 408,
|
* CustomException("Timeout waiting for transaction completion", "FAILED", 408,
|
||||||
* "Transaction still in progress"); }
|
* "Transaction still in progress"); }
|
||||||
*
|
*
|
||||||
* Thread.sleep(intervalMs); continue; }
|
* Thread.sleep(intervalMs); continue; }
|
||||||
*
|
*
|
||||||
* ResponseModel responseModel = new ResponseModel( generalResp.getMessage(),
|
* ResponseModel responseModel = new ResponseModel( generalResp.getMessage(),
|
||||||
* generalResp.getStatus(), Integer.parseInt(generalResp.getStatusCode()),
|
* generalResp.getStatus(), Integer.parseInt(generalResp.getStatusCode()),
|
||||||
* responseWrapper );
|
* responseWrapper );
|
||||||
*
|
*
|
||||||
* helper.updateInboundLogSuccess(inboundLog, responseData,
|
* helper.updateInboundLogSuccess(inboundLog, responseData,
|
||||||
* generalResp.getStatus()); return responseModel;
|
* generalResp.getStatus()); return responseModel;
|
||||||
*
|
*
|
||||||
* } catch (JsonProcessingException e) {
|
* } catch (JsonProcessingException e) {
|
||||||
* LOGGER.error("Error parsing transaction status JSON: {}", e.getMessage());
|
* LOGGER.error("Error parsing transaction status JSON: {}", e.getMessage());
|
||||||
* helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
* helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||||
* throw new CustomException("Invalid JSON received from API"); } catch
|
* throw new CustomException("Invalid JSON received from API"); } catch
|
||||||
* (InterruptedException e) { Thread.currentThread().interrupt();
|
* (InterruptedException e) { Thread.currentThread().interrupt();
|
||||||
* helper.updateInboundLogFailure(inboundLog, e.getMessage(), "INTERRUPTED");
|
* helper.updateInboundLogFailure(inboundLog, e.getMessage(), "INTERRUPTED");
|
||||||
* throw new CustomException("Thread interrupted during transaction check"); } }
|
* throw new CustomException("Thread interrupted during transaction check"); } }
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -18,13 +18,17 @@ import com.billpaymentservice.bbps.dto.CustomerParamDAO;
|
|||||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||||
import com.billpaymentservice.bbps.dto.request.BillFetchByBillIdRequest;
|
import com.billpaymentservice.bbps.dto.request.BillFetchByBillIdRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
|
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.request.ComplaintRequestDTO;
|
||||||
import com.billpaymentservice.bbps.dto.request.FetchBillRequest;
|
import com.billpaymentservice.bbps.dto.request.FetchBillRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.FetchBillValidatestRequest;
|
import com.billpaymentservice.bbps.dto.request.FetchBillValidatestRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.request.GetTicketLatestStausRequest;
|
||||||
import com.billpaymentservice.bbps.dto.response.BillDataResponse;
|
import com.billpaymentservice.bbps.dto.response.BillDataResponse;
|
||||||
import com.billpaymentservice.bbps.dto.response.FetchBillValidateResponse;
|
import com.billpaymentservice.bbps.dto.response.FetchBillValidateResponse;
|
||||||
import com.billpaymentservice.bbps.dto.sentRequest.BillPaymentForwardRequest;
|
import com.billpaymentservice.bbps.dto.sentRequest.BillPaymentForwardRequest;
|
||||||
import com.billpaymentservice.bbps.dto.sentRequest.FetchBillForwardRequest;
|
import com.billpaymentservice.bbps.dto.sentRequest.FetchBillForwardRequest;
|
||||||
import com.billpaymentservice.bbps.dto.sentRequest.FetchBillValidatestForwardRequest;
|
import com.billpaymentservice.bbps.dto.sentRequest.FetchBillValidatestForwardRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.sentRequest.FetchComplaintForwardRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.sentRequest.FetchTicketLatestStatusRequest;
|
||||||
import com.billpaymentservice.bbps.entites.AdditionalInfoBill;
|
import com.billpaymentservice.bbps.entites.AdditionalInfoBill;
|
||||||
import com.billpaymentservice.bbps.entites.AdditionalInfoBillValidate;
|
import com.billpaymentservice.bbps.entites.AdditionalInfoBillValidate;
|
||||||
import com.billpaymentservice.bbps.entites.BBPSMastersData;
|
import com.billpaymentservice.bbps.entites.BBPSMastersData;
|
||||||
@@ -65,14 +69,14 @@ public class Helper {
|
|||||||
|
|
||||||
// Constructor Injection
|
// Constructor Injection
|
||||||
public Helper(BBPSMasterDataRepo bbpsMasterDataRepo, InboundTraceLogRepository inboundTraceLogRepository,
|
public Helper(BBPSMasterDataRepo bbpsMasterDataRepo, InboundTraceLogRepository inboundTraceLogRepository,
|
||||||
OutboundTraceLogRepository outboundTraceLogRepository,BillerDataRepository billerDataRepository,
|
OutboundTraceLogRepository outboundTraceLogRepository, BillerDataRepository billerDataRepository,
|
||||||
BillMasterRepository billMasterRepository,BillValidationRepository billValidationRepository) {
|
BillMasterRepository billMasterRepository, BillValidationRepository billValidationRepository) {
|
||||||
this.bbpsMasterDataRepo = bbpsMasterDataRepo;
|
this.bbpsMasterDataRepo = bbpsMasterDataRepo;
|
||||||
this.inboundTraceLogRepository = inboundTraceLogRepository;
|
this.inboundTraceLogRepository = inboundTraceLogRepository;
|
||||||
this.outboundTraceLogRepository = outboundTraceLogRepository;
|
this.outboundTraceLogRepository = outboundTraceLogRepository;
|
||||||
this.billerDataRespository=billerDataRepository;
|
this.billerDataRespository = billerDataRepository;
|
||||||
this.billMasterRepository=billMasterRepository;
|
this.billMasterRepository = billMasterRepository;
|
||||||
this.billValidationRepository=billValidationRepository;
|
this.billValidationRepository = billValidationRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -163,14 +167,14 @@ public class Helper {
|
|||||||
return "{}"; // or "N/A" depending on your needs
|
return "{}"; // or "N/A" depending on your needs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------- Trace helper methods ---------- */
|
/* ---------- Trace helper methods ---------- */
|
||||||
|
|
||||||
public InboundTraceLog createInboundLog(String requestId, String txnId, String apiName, String mid,
|
public InboundTraceLog createInboundLog(String requestId, String txnId, String apiName, String mid,
|
||||||
String httpMethod, String requestPayload) {
|
String httpMethod, String requestPayload) {
|
||||||
if(inboundTraceLogRepository.findByRequestId(requestId) != null) {
|
if (inboundTraceLogRepository.findByRequestId(requestId) != null) {
|
||||||
throw new CustomException("Duplicate Request ID: " + requestId);
|
throw new CustomException("Duplicate Request ID: " + requestId);
|
||||||
}
|
}
|
||||||
InboundTraceLog inboundLog = new InboundTraceLog(requestId, txnId, apiName, mid == null ? "N/A" : mid,
|
InboundTraceLog inboundLog = new InboundTraceLog(requestId, txnId, apiName, mid == null ? "N/A" : mid,
|
||||||
"BBPS_ORG", httpMethod, requestPayload == null ? "N/A" : requestPayload);
|
"BBPS_ORG", httpMethod, requestPayload == null ? "N/A" : requestPayload);
|
||||||
inboundTraceLogRepository.save(inboundLog);
|
inboundTraceLogRepository.save(inboundLog);
|
||||||
@@ -187,7 +191,7 @@ public class Helper {
|
|||||||
inboundTraceLogRepository.save(inboundLog);
|
inboundTraceLogRepository.save(inboundLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateInboundLogFailure(InboundTraceLog inboundLog, String responsePayload, String responseCode) {
|
public void updateInboundLogFailure(InboundTraceLog inboundLog, String responsePayload, String responseCode) {
|
||||||
if (inboundLog == null)
|
if (inboundLog == null)
|
||||||
return;
|
return;
|
||||||
inboundLog.setResponsePayload(responsePayload);
|
inboundLog.setResponsePayload(responsePayload);
|
||||||
@@ -211,202 +215,208 @@ public class Helper {
|
|||||||
outboundLog.setResponsePayload(responsePayload);
|
outboundLog.setResponsePayload(responsePayload);
|
||||||
outboundLog.setResponseReceiveTime(LocalDateTime.now());
|
outboundLog.setResponseReceiveTime(LocalDateTime.now());
|
||||||
outboundTraceLogRepository.save(outboundLog);
|
outboundTraceLogRepository.save(outboundLog);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------- End helpers ---------- */
|
/* ---------- End helpers ---------- */
|
||||||
public void saveOrUpdateBillerData(BillerDetails newEntity) {
|
public void saveOrUpdateBillerData(BillerDetails newEntity) {
|
||||||
|
|
||||||
Optional<BillerDetails> existingOpt = billerDataRespository.findByBillerId(newEntity.getBillerId());
|
Optional<BillerDetails> existingOpt = billerDataRespository.findByBillerId(newEntity.getBillerId());
|
||||||
|
|
||||||
if (existingOpt.isPresent()) {
|
if (existingOpt.isPresent()) {
|
||||||
//logic to be written
|
// logic to be written
|
||||||
}
|
} else {
|
||||||
else {
|
// brand new biller
|
||||||
// brand new biller
|
billerDataRespository.save(newEntity);
|
||||||
billerDataRespository.save(newEntity);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveOrUpdateBillData(BillDataResponse responseWrapper,
|
public void saveOrUpdateBillData(BillDataResponse responseWrapper,
|
||||||
BillFetchByBillIdRequest billFetchByBillIdRequest,String txnId) {
|
BillFetchByBillIdRequest billFetchByBillIdRequest, String txnId) {
|
||||||
|
|
||||||
|
BillMaster billMaster = new BillMaster();
|
||||||
|
|
||||||
BillMaster billMaster = new BillMaster();
|
billMaster.setBillId(billFetchByBillIdRequest.getBillId());
|
||||||
|
billMaster.setRefId(responseWrapper.getRefId());
|
||||||
billMaster.setBillId(billFetchByBillIdRequest.getBillId());
|
billMaster.setBillerId(responseWrapper.getBillerId());
|
||||||
billMaster.setRefId(responseWrapper.getRefId());
|
billMaster.setStatus(responseWrapper.getStatus());
|
||||||
billMaster.setBillerId(responseWrapper.getBillerId());
|
billMaster.setActionType(responseWrapper.getActionType());
|
||||||
billMaster.setStatus(responseWrapper.getStatus());
|
billMaster.setUserId(responseWrapper.getUserId());
|
||||||
billMaster.setActionType(responseWrapper.getActionType());
|
billMaster.setReqId(billFetchByBillIdRequest.getReqId());
|
||||||
billMaster.setUserId(responseWrapper.getUserId());
|
billMaster.setTxnId(txnId);
|
||||||
billMaster.setReqId(billFetchByBillIdRequest.getReqId());
|
|
||||||
billMaster.setTxnId(txnId);
|
|
||||||
|
|
||||||
|
|
||||||
// BILLER RESPONSE
|
// BILLER RESPONSE
|
||||||
BillerResponse billerResponse = new BillerResponse();
|
BillerResponse billerResponse = new BillerResponse();
|
||||||
if (responseWrapper.getBillerResponse() != null) {
|
if (responseWrapper.getBillerResponse() != null) {
|
||||||
billerResponse.setBillId(responseWrapper.getBillerResponse().getBillId());
|
billerResponse.setBillId(responseWrapper.getBillerResponse().getBillId());
|
||||||
billerResponse.setAmount(responseWrapper.getBillerResponse().getAmount());
|
billerResponse.setAmount(responseWrapper.getBillerResponse().getAmount());
|
||||||
billerResponse.setBillDate(responseWrapper.getBillerResponse().getBillDate());
|
billerResponse.setBillDate(responseWrapper.getBillerResponse().getBillDate());
|
||||||
billerResponse.setBillNumber(responseWrapper.getBillerResponse().getBillNumber());
|
billerResponse.setBillNumber(responseWrapper.getBillerResponse().getBillNumber());
|
||||||
billerResponse.setBillPeriod(responseWrapper.getBillerResponse().getBillPeriod());
|
billerResponse.setBillPeriod(responseWrapper.getBillerResponse().getBillPeriod());
|
||||||
billerResponse.setCustConvFee(responseWrapper.getBillerResponse().getCustConvFee());
|
billerResponse.setCustConvFee(responseWrapper.getBillerResponse().getCustConvFee());
|
||||||
billerResponse.setCouCustConvFee(responseWrapper.getBillerResponse().getCouCustConvFee());
|
billerResponse.setCouCustConvFee(responseWrapper.getBillerResponse().getCouCustConvFee());
|
||||||
billerResponse.setDueDate(responseWrapper.getBillerResponse().getDueDate());
|
billerResponse.setDueDate(responseWrapper.getBillerResponse().getDueDate());
|
||||||
billerResponse.setCustomerName(responseWrapper.getBillerResponse().getCustomerName());
|
billerResponse.setCustomerName(responseWrapper.getBillerResponse().getCustomerName());
|
||||||
billerResponse.setAmountOption(responseWrapper.getBillerResponse().isAmountOption());
|
billerResponse.setAmountOption(responseWrapper.getBillerResponse().isAmountOption());
|
||||||
billerResponse.setBillMaster(billMaster);
|
billerResponse.setBillMaster(billMaster);
|
||||||
}
|
}
|
||||||
billMaster.setBillerResponse(billerResponse);
|
billMaster.setBillerResponse(billerResponse);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ADDITIONAL INFO
|
// ADDITIONAL INFO
|
||||||
List<AdditionalInfoBill> additionalInfos = new ArrayList<>();
|
List<AdditionalInfoBill> additionalInfos = new ArrayList<>();
|
||||||
if (responseWrapper.getAdditionalInfo() != null) {
|
if (responseWrapper.getAdditionalInfo() != null) {
|
||||||
for (AdditionalInfoBillDTO info : responseWrapper.getAdditionalInfo()) {
|
for (AdditionalInfoBillDTO info : responseWrapper.getAdditionalInfo()) {
|
||||||
AdditionalInfoBill entity = new AdditionalInfoBill();
|
AdditionalInfoBill entity = new AdditionalInfoBill();
|
||||||
entity.setName(info.getName());
|
entity.setName(info.getName());
|
||||||
entity.setValue(info.getValue());
|
entity.setValue(info.getValue());
|
||||||
entity.setBillMaster(billMaster);
|
entity.setBillMaster(billMaster);
|
||||||
additionalInfos.add(entity);
|
additionalInfos.add(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
billMaster.setAdditionalInfo(additionalInfos);
|
billMaster.setAdditionalInfo(additionalInfos);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// CUSTOMER PARAMS
|
// CUSTOMER PARAMS
|
||||||
List<CustomerParamBill> customerParams = new ArrayList<>();
|
List<CustomerParamBill> customerParams = new ArrayList<>();
|
||||||
if (responseWrapper.getCustomerParams() != null) {
|
if (responseWrapper.getCustomerParams() != null) {
|
||||||
for (CustomerParamDAO param : responseWrapper.getCustomerParams()) {
|
for (CustomerParamDAO param : responseWrapper.getCustomerParams()) {
|
||||||
CustomerParamBill entity = new CustomerParamBill();
|
CustomerParamBill entity = new CustomerParamBill();
|
||||||
entity.setName(param.getName());
|
entity.setName(param.getName());
|
||||||
entity.setValue(param.getValue() == null ? "" : param.getValue());
|
entity.setValue(param.getValue() == null ? "" : param.getValue());
|
||||||
entity.setType(param.getType() == null ? "" : param.getType());
|
entity.setType(param.getType() == null ? "" : param.getType());
|
||||||
entity.setBillMaster(billMaster);
|
entity.setBillMaster(billMaster);
|
||||||
customerParams.add(entity);
|
customerParams.add(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
billMaster.setCustomerParams(customerParams);
|
billMaster.setCustomerParams(customerParams);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// DATES
|
// DATES
|
||||||
billMaster.setCreationDate(responseWrapper.getCreationDate());
|
billMaster.setCreationDate(responseWrapper.getCreationDate());
|
||||||
billMaster.setModifiedDate(responseWrapper.getModifiedDate());
|
billMaster.setModifiedDate(responseWrapper.getModifiedDate());
|
||||||
billMaster.setCreatedEpochDate(responseWrapper.getCreatedEpochDate());
|
billMaster.setCreatedEpochDate(responseWrapper.getCreatedEpochDate());
|
||||||
billMaster.setModifiedEpochDate(responseWrapper.getModifiedEpochDate());
|
billMaster.setModifiedEpochDate(responseWrapper.getModifiedEpochDate());
|
||||||
|
|
||||||
|
billMasterRepository.save(billMaster);
|
||||||
|
}
|
||||||
|
|
||||||
billMasterRepository.save(billMaster);
|
public void saveBillValidation(FetchBillValidateResponse responseWrapper, BillFetchByBillIdRequest billRequest) {
|
||||||
}
|
System.out.println("responseWrapper");
|
||||||
|
ModelMapper modelMapper = new ModelMapper();
|
||||||
|
|
||||||
public void saveBillValidation(FetchBillValidateResponse responseWrapper, BillFetchByBillIdRequest billRequest) {
|
try {
|
||||||
System.out.println("responseWrapper");
|
LOGGER.info("Saving bill validation data for billId={}", responseWrapper.getBillId());
|
||||||
ModelMapper modelMapper = new ModelMapper();
|
|
||||||
|
|
||||||
try {
|
|
||||||
LOGGER.info("Saving bill validation data for billId={}", responseWrapper.getBillId());
|
|
||||||
|
|
||||||
// ✅ Map the main object
|
// ✅ Map the main object
|
||||||
BillValidation billEntity = modelMapper.map(responseWrapper, BillValidation.class);
|
BillValidation billEntity = modelMapper.map(responseWrapper, BillValidation.class);
|
||||||
// ✅ Manually handle only the nested relationship part
|
// ✅ Manually handle only the nested relationship part
|
||||||
if (responseWrapper.getCustomerParams() != null) {
|
if (responseWrapper.getCustomerParams() != null) {
|
||||||
List<CustomerParamBillValidation> customerParams = responseWrapper.getCustomerParams()
|
List<CustomerParamBillValidation> customerParams = responseWrapper.getCustomerParams().stream()
|
||||||
.stream()
|
.map(param -> {
|
||||||
.map(param -> {
|
CustomerParamBillValidation cp = modelMapper.map(param, CustomerParamBillValidation.class);
|
||||||
CustomerParamBillValidation cp = modelMapper.map(param, CustomerParamBillValidation.class);
|
cp.setBill(billEntity); // maintain relation
|
||||||
cp.setBill(billEntity); // maintain relation
|
return cp;
|
||||||
return cp;
|
}).collect(Collectors.toList());
|
||||||
})
|
billEntity.setCustomerParams(customerParams);
|
||||||
.collect(Collectors.toList());
|
}
|
||||||
billEntity.setCustomerParams(customerParams);
|
if (responseWrapper.getAdditionalInfo() != null) {
|
||||||
}
|
List<AdditionalInfoBillValidate> additionalInfos = responseWrapper.getAdditionalInfo().stream()
|
||||||
if (responseWrapper.getAdditionalInfo() != null) {
|
.map(info -> {
|
||||||
List<AdditionalInfoBillValidate> additionalInfos = responseWrapper.getAdditionalInfo()
|
AdditionalInfoBillValidate ai = modelMapper.map(info, AdditionalInfoBillValidate.class);
|
||||||
.stream()
|
ai.setBill(billEntity); // maintain relation
|
||||||
.map(info -> {
|
return ai;
|
||||||
AdditionalInfoBillValidate ai = modelMapper.map(info, AdditionalInfoBillValidate.class);
|
}).collect(Collectors.toList());
|
||||||
ai.setBill(billEntity); // maintain relation
|
billEntity.setAdditionalInfo(additionalInfos);
|
||||||
return ai;
|
|
||||||
})
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
billEntity.setAdditionalInfo(additionalInfos);
|
|
||||||
|
|
||||||
}
|
|
||||||
// ✅ Save everything (cascade handles child)
|
|
||||||
|
|
||||||
billValidationRepository.save(billEntity);
|
|
||||||
|
|
||||||
LOGGER.info("Bill validation saved successfully for billId={}", billEntity.getBillId());
|
}
|
||||||
} catch (Exception ex) {
|
// ✅ Save everything (cascade handles child)
|
||||||
LOGGER.error("Error saving BillValidation data: {}", ex.getMessage(), ex);
|
|
||||||
throw new RuntimeException("Failed to save bill validation data", ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
billValidationRepository.save(billEntity);
|
||||||
}
|
|
||||||
|
|
||||||
public FetchBillForwardRequest fetchBillForwardRequestMap(FetchBillRequest req) {
|
|
||||||
|
|
||||||
FetchBillForwardRequest forward = new FetchBillForwardRequest();
|
LOGGER.info("Bill validation saved successfully for billId={}", billEntity.getBillId());
|
||||||
|
} catch (Exception ex) {
|
||||||
|
LOGGER.error("Error saving BillValidation data: {}", ex.getMessage(), ex);
|
||||||
|
throw new RuntimeException("Failed to save bill validation data", ex);
|
||||||
|
}
|
||||||
|
|
||||||
forward.setBillerId(req.getBillerId());
|
}
|
||||||
forward.setBillerName(req.getBillerName());
|
|
||||||
forward.setBillerCategory(req.getBillerCategory());
|
|
||||||
forward.setClientReqId(req.getClientReqId());
|
|
||||||
forward.setMacAdress(req.getMacAdress());
|
|
||||||
forward.setCustomerMobNo(req.getCustomerMobNo());
|
|
||||||
forward.setRemitterName(req.getRemitterName());
|
|
||||||
forward.setPaymentChannel(req.getPaymentChannel());
|
|
||||||
forward.setDeviceBlockTags(req.getDeviceBlockTags());
|
|
||||||
forward.setCustomerParamsRequest(req.getCustomerParamsRequest());
|
|
||||||
forward.setRemitterIdentity(req.getRemitterIdentity());
|
|
||||||
|
|
||||||
return forward;
|
public FetchBillForwardRequest fetchBillForwardRequestMap(FetchBillRequest req) {
|
||||||
}
|
|
||||||
|
|
||||||
public FetchBillValidatestForwardRequest fetchBillValidatestForwardRequest(FetchBillValidatestRequest req) {
|
|
||||||
|
|
||||||
FetchBillValidatestForwardRequest forward = new FetchBillValidatestForwardRequest();
|
FetchBillForwardRequest forward = new FetchBillForwardRequest();
|
||||||
|
|
||||||
forward.setBillerId(req.getBillerId());
|
forward.setBillerId(req.getBillerId());
|
||||||
forward.setBillerName(req.getBillerName());
|
forward.setBillerName(req.getBillerName());
|
||||||
forward.setBillerCategory(req.getBillerCategory());
|
forward.setBillerCategory(req.getBillerCategory());
|
||||||
forward.setCustomerMobNo(req.getCustomerMobNo());
|
forward.setClientReqId(req.getClientReqId());
|
||||||
forward.setClientReqId(req.getClientReqId());
|
forward.setMacAdress(req.getMacAdress());
|
||||||
forward.setMacAddress(req.getMacAddress());
|
forward.setCustomerMobNo(req.getCustomerMobNo());
|
||||||
forward.setCustomerParamsRequest(req.getCustomerParamsRequest());
|
forward.setRemitterName(req.getRemitterName());
|
||||||
|
forward.setPaymentChannel(req.getPaymentChannel());
|
||||||
|
forward.setDeviceBlockTags(req.getDeviceBlockTags());
|
||||||
|
forward.setCustomerParamsRequest(req.getCustomerParamsRequest());
|
||||||
|
forward.setRemitterIdentity(req.getRemitterIdentity());
|
||||||
|
|
||||||
return forward;
|
return forward;
|
||||||
}
|
}
|
||||||
public BillPaymentForwardRequest billPaymentForwardRequest(BillPaymentRequest req) {
|
|
||||||
|
|
||||||
BillPaymentForwardRequest forward = new BillPaymentForwardRequest();
|
public FetchBillValidatestForwardRequest fetchBillValidatestForwardRequest(FetchBillValidatestRequest req) {
|
||||||
|
|
||||||
forward.setTenantId(req.getTenantId());
|
FetchBillValidatestForwardRequest forward = new FetchBillValidatestForwardRequest();
|
||||||
forward.setRefId(req.getRefId());
|
|
||||||
forward.setBillId(req.getBillId());
|
|
||||||
forward.setAmountOptions(req.isAmountOptions());
|
|
||||||
forward.setPaymentMode(req.getPaymentMode());
|
|
||||||
forward.setPaymentInformation(req.getPaymentInformation());
|
|
||||||
forward.setBillerId(req.getBillerId());
|
|
||||||
forward.setBillerName(req.getBillerName());
|
|
||||||
forward.setBillerCategory(req.getBillerCategory());
|
|
||||||
forward.setMacAdress(req.getMacAdress());
|
|
||||||
forward.setCustomerMobNo(req.getCustomerMobNo());
|
|
||||||
forward.setTxnAmount(req.getTxnAmount());
|
|
||||||
forward.setPaymentRefId(req.getPaymentRefId());
|
|
||||||
forward.setClientReqId(req.getClientReqId());
|
|
||||||
forward.setPaymentChannel(req.getPaymentChannel());
|
|
||||||
|
|
||||||
forward.setDeviceBlockTags(req.getDeviceBlockTags());
|
forward.setBillerId(req.getBillerId());
|
||||||
forward.setCustomerParamsRequest(req.getCustomerParamsRequest());
|
forward.setBillerName(req.getBillerName());
|
||||||
forward.setRemitterIdentity(req.getRemitterIdentity());
|
forward.setBillerCategory(req.getBillerCategory());
|
||||||
forward.setAmountBreakSet(req.getAmountBreakSet());
|
forward.setCustomerMobNo(req.getCustomerMobNo());
|
||||||
|
forward.setClientReqId(req.getClientReqId());
|
||||||
|
forward.setMacAddress(req.getMacAddress());
|
||||||
|
forward.setCustomerParamsRequest(req.getCustomerParamsRequest());
|
||||||
|
|
||||||
return forward;
|
return forward;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BillPaymentForwardRequest billPaymentForwardRequest(BillPaymentRequest req) {
|
||||||
|
|
||||||
|
BillPaymentForwardRequest forward = new BillPaymentForwardRequest();
|
||||||
|
|
||||||
|
forward.setTenantId(req.getTenantId());
|
||||||
|
forward.setRefId(req.getRefId());
|
||||||
|
forward.setBillId(req.getBillId());
|
||||||
|
forward.setAmountOptions(req.isAmountOptions());
|
||||||
|
forward.setPaymentMode(req.getPaymentMode());
|
||||||
|
forward.setPaymentInformation(req.getPaymentInformation());
|
||||||
|
forward.setBillerId(req.getBillerId());
|
||||||
|
forward.setBillerName(req.getBillerName());
|
||||||
|
forward.setBillerCategory(req.getBillerCategory());
|
||||||
|
forward.setMacAdress(req.getMacAdress());
|
||||||
|
forward.setCustomerMobNo(req.getCustomerMobNo());
|
||||||
|
forward.setTxnAmount(req.getTxnAmount());
|
||||||
|
forward.setPaymentRefId(req.getPaymentRefId());
|
||||||
|
forward.setClientReqId(req.getClientReqId());
|
||||||
|
forward.setPaymentChannel(req.getPaymentChannel());
|
||||||
|
|
||||||
|
forward.setDeviceBlockTags(req.getDeviceBlockTags());
|
||||||
|
forward.setCustomerParamsRequest(req.getCustomerParamsRequest());
|
||||||
|
forward.setRemitterIdentity(req.getRemitterIdentity());
|
||||||
|
forward.setAmountBreakSet(req.getAmountBreakSet());
|
||||||
|
|
||||||
|
return forward;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FetchComplaintForwardRequest fetchComplaintForwardRequestMap(ComplaintRequestDTO complainRequestDTO) {
|
||||||
|
FetchComplaintForwardRequest forward = new FetchComplaintForwardRequest();
|
||||||
|
|
||||||
|
forward.setBillerId(complainRequestDTO.getBillerId());
|
||||||
|
forward.setBillerName(complainRequestDTO.getBillerName());
|
||||||
|
forward.setTicketDescription(complainRequestDTO.getTicketDescription());
|
||||||
|
forward.setTicketDisposition(complainRequestDTO.getTicketDisposition());
|
||||||
|
forward.setTicketDispositionCode(complainRequestDTO.getTicketDispositionCode());
|
||||||
|
forward.setTxnId(complainRequestDTO.getTxnId());
|
||||||
|
return forward;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FetchTicketLatestStatusRequest fetchTicketLatestStatusRequestMap(GetTicketLatestStausRequest request) {
|
||||||
|
FetchTicketLatestStatusRequest forward = new FetchTicketLatestStatusRequest();
|
||||||
|
forward.setTicketId(request.getTicketId());
|
||||||
|
forward.setTxnNpciId(request.getTxnNpciId());
|
||||||
|
return forward;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -20,9 +20,9 @@ swagger.server.description=Local Development Server
|
|||||||
# DataSource
|
# DataSource
|
||||||
spring.datasource.url=jdbc:postgresql://localhost:5432/BBPS
|
spring.datasource.url=jdbc:postgresql://localhost:5432/BBPS
|
||||||
spring.datasource.username=postgres
|
spring.datasource.username=postgres
|
||||||
#spring.datasource.password=UAT@DB_2025
|
spring.datasource.password=UAT@DB_2025
|
||||||
|
|
||||||
spring.datasource.password=himanshu@123
|
#spring.datasource.password=himanshu@123
|
||||||
spring.datasource.driver-class-name=org.postgresql.Driver
|
spring.datasource.driver-class-name=org.postgresql.Driver
|
||||||
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
|
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user