added constant in bbps constant
This commit is contained in:
@@ -6,8 +6,7 @@ import java.util.Optional;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestClient;
|
||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||
@@ -22,7 +21,6 @@ import com.billpaymentservice.bbps.dto.response.FetchBillResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.FetchBillValidateResponse;
|
||||
import com.billpaymentservice.bbps.dto.sentRequest.FetchBillForwardRequest;
|
||||
import com.billpaymentservice.bbps.dto.sentRequest.FetchBillValidatestForwardRequest;
|
||||
import com.billpaymentservice.bbps.entites.BharatConnectMaster;
|
||||
import com.billpaymentservice.bbps.entites.BillInitiate;
|
||||
import com.billpaymentservice.bbps.entites.BillMaster;
|
||||
import com.billpaymentservice.bbps.entites.InboundTraceLog;
|
||||
@@ -41,7 +39,6 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Service
|
||||
public class AgentServiceImpl implements AgentService {
|
||||
@@ -80,7 +77,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
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 = BBPSConstant.API_INITIATE_BILL_FETCH;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String requestId = fetchBillRequest.getReqId();
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_INTI;
|
||||
@@ -93,8 +90,8 @@ public class AgentServiceImpl implements AgentService {
|
||||
String requestJson = helper.convertObjectToJson(fetchBillRequest);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, fetchBillRequest.getMid(),
|
||||
"POST", requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, fullUrl, "POST",
|
||||
BBPSConstant.HTTP_POST, requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, fullUrl, BBPSConstant.HTTP_POST,
|
||||
forwardJson);
|
||||
LOGGER.debug("Outbound log created successfully for txnId: {} and reqId: {}", txnId, requestId);
|
||||
|
||||
@@ -107,10 +104,10 @@ public class AgentServiceImpl implements AgentService {
|
||||
LOGGER.debug("Response received from BBPS: {}", responseData);
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
LOGGER.warn("Invalid response received for txnId: {}", txnId);
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
@@ -150,7 +147,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
return fetchBillById(billFetchByBillIdRequest, inboundLog);
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("JSON Parsing Error: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
@@ -158,14 +155,14 @@ public class AgentServiceImpl implements AgentService {
|
||||
public ResponseModel fetchBillById(BillFetchByBillIdRequest billFetchByBillIdRequest, InboundTraceLog inboundLog) {
|
||||
LOGGER.info("Fetching bill by BILLID for request ID={} and MID={}", billFetchByBillIdRequest.getReqId(),
|
||||
billFetchByBillIdRequest.getMid());
|
||||
String apiName = "FetchBillById";
|
||||
String apiName = BBPSConstant.API_FETCH_BILL_BY_ID;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = billFetchByBillIdRequest.getReqId();
|
||||
String billId = billFetchByBillIdRequest.getBillId();
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + billFetchByBillIdRequest.getBillId();
|
||||
helper.validateMerchant(billFetchByBillIdRequest.getMid());
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.debug("Outbound log created successfully for FetchBillById: {}", fullUrl);
|
||||
|
||||
try {
|
||||
@@ -177,11 +174,11 @@ public class AgentServiceImpl implements AgentService {
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
LOGGER.warn("Invalid response structure for txnId: {}", txnId);
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
@@ -202,14 +199,14 @@ public class AgentServiceImpl implements AgentService {
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing BillById JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel fetchBillById(BillFetchByBillIdRequest billFetchByBillIdRequest) {
|
||||
String apiName = "FetchBillById";
|
||||
String apiName = BBPSConstant.API_FETCH_BILL_BY_ID;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = billFetchByBillIdRequest.getReqId();
|
||||
String billId = billFetchByBillIdRequest.getBillId();
|
||||
@@ -218,13 +215,13 @@ public class AgentServiceImpl implements AgentService {
|
||||
LOGGER.info("Initiating {} API for billId={} and reqId={}", apiName, billId, reqId);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName,
|
||||
billFetchByBillIdRequest.getMid(), "GET", null);
|
||||
billFetchByBillIdRequest.getMid(), BBPSConstant.HTTP_GET, null);
|
||||
|
||||
try {
|
||||
helper.validateMerchant(billFetchByBillIdRequest.getMid());
|
||||
LOGGER.debug("Merchant validated successfully for MID={}", billFetchByBillIdRequest.getMid());
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.info("Calling external BBPS API for FetchBillById, URL={}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, helper.buildHeaders(beneficiaryDetailsRepository.findByOrgId("ORG001")));
|
||||
String responseData = responseMap.get("data");
|
||||
@@ -237,7 +234,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
LOGGER.warn("Invalid response structure received for billId={} | Response={}", billId, responseData);
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")),
|
||||
String.valueOf(dataMap.get("status")),
|
||||
@@ -258,7 +255,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON for billId={} : {}", billId, e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
@@ -268,7 +265,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
LOGGER.info("Initiating bill Validate for request ID: {} and MID:{} and billerId:{}", fetchBillValidateRequest.getReqId(),
|
||||
fetchBillValidateRequest.getMid(),fetchBillValidateRequest.getBillerId());
|
||||
|
||||
String apiName = "InitiateBillValidate";
|
||||
String apiName = BBPSConstant.API_INITIATE_BILL_VALIDATE;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = fetchBillValidateRequest.getReqId();
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILLER_VALIDATE_URL;
|
||||
@@ -283,8 +280,8 @@ public class AgentServiceImpl implements AgentService {
|
||||
String requestJson = helper.convertObjectToJson(fetchBillValidateRequest);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, fetchBillValidateRequest.getMid(),
|
||||
"POST", requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "POST", forwardJson);
|
||||
BBPSConstant.HTTP_POST, requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_POST, forwardJson);
|
||||
LOGGER.debug("Outbound log created successfully for txnId: {} and reqId: {}", txnId, reqId);
|
||||
|
||||
try {
|
||||
@@ -296,10 +293,10 @@ public class AgentServiceImpl implements AgentService {
|
||||
LOGGER.debug("Response received from BBPS: {}", responseData);
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
LOGGER.warn("Invalid response received for txnId: {}", txnId);
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
@@ -338,7 +335,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
return BillvaidateByBillId(billFetchByBillIdRequest, inboundLog);
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("JSON Parsing Error: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
@@ -347,7 +344,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
{
|
||||
LOGGER.info("Validating bill by BILLID for request ID={} and MID={}", billRequest.getReqId(),
|
||||
billRequest.getMid());
|
||||
String apiName = "FetchBillById";
|
||||
String apiName = BBPSConstant.API_FETCH_BILL_BY_ID;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = billRequest.getReqId();
|
||||
String billId = billRequest.getBillId();
|
||||
@@ -355,7 +352,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
|
||||
helper.validateMerchant(billRequest.getMid());
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.debug("Outbound log created successfully for FetchBillById: {}", fullUrl);
|
||||
|
||||
try {
|
||||
@@ -367,11 +364,11 @@ public class AgentServiceImpl implements AgentService {
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
LOGGER.warn("Invalid response structure for txnId: {}", txnId);
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
@@ -394,7 +391,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing BillById JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
|
||||
@@ -403,7 +400,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
|
||||
@Override
|
||||
public ResponseModel initiateBillValidateByBillId(BillFetchByBillIdRequest billRequest) {
|
||||
String apiName = "FetchBillById";
|
||||
String apiName = BBPSConstant.API_FETCH_BILL_BY_ID;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = billRequest.getReqId();
|
||||
String billId = billRequest.getBillId();
|
||||
@@ -411,12 +408,12 @@ public class AgentServiceImpl implements AgentService {
|
||||
|
||||
LOGGER.info("Initiating {} API for billId={} and reqId={}", apiName, billId, reqId);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, billRequest.getMid(), "GET", null);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, billRequest.getMid(), BBPSConstant.HTTP_GET, null);
|
||||
|
||||
try {
|
||||
helper.validateMerchant(billRequest.getMid());
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.info("Calling external BBPS API for ValidateByBillId, URL={}", fullUrl);
|
||||
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, helper.buildHeaders(beneficiaryDetailsRepository.findByOrgId("ORG001")));
|
||||
@@ -428,7 +425,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData, new com.fasterxml.jackson.core.type.TypeReference<Map<String, Object>>(){});
|
||||
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
LOGGER.warn("Invalid response structure received for billId={} | Response={}", billId, responseData);
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")),
|
||||
String.valueOf(dataMap.get("status")),
|
||||
@@ -447,7 +444,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
|
||||
} catch (com.fasterxml.jackson.core.JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing ValidateByBillId JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
@@ -457,14 +454,14 @@ public class AgentServiceImpl implements AgentService {
|
||||
@Override
|
||||
public ResponseModel fetchBillValidateByClientReqId(BillValidateByClientIdRequest billValidateByClientIdRequest) {
|
||||
|
||||
String apiName = "FetchBillValidateByClientIdRequest";
|
||||
String apiName = BBPSConstant.API_FETCH_BILL_VALIDATE_BY_CLIENT_ID;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = billValidateByClientIdRequest.getReqId();
|
||||
String clientReqId = billValidateByClientIdRequest.getClientReqId();
|
||||
|
||||
Optional<BillInitiate> billInitiate = billIntiateRepository.findByReqId(clientReqId);
|
||||
if (billInitiate.isEmpty()) {
|
||||
throw new CustomException("No Bill Found for given Client Req Id");
|
||||
throw new CustomException(BBPSConstant.NO_BILL_FOUND);
|
||||
}
|
||||
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_VALIDATE_BY_CLIENT_REQ_ID + billInitiate.get().getTxnId();
|
||||
@@ -472,9 +469,9 @@ public class AgentServiceImpl implements AgentService {
|
||||
helper.validateMerchant(billValidateByClientIdRequest.getMid());
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName,
|
||||
billValidateByClientIdRequest.getMid(), "GET", null);
|
||||
billValidateByClientIdRequest.getMid(), BBPSConstant.HTTP_GET, null);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling BBPS API FetchBillValidateByClientReqId, URL={}", fullUrl);
|
||||
@@ -484,11 +481,11 @@ public class AgentServiceImpl implements AgentService {
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
String.valueOf(dataMap.get("remarks")));
|
||||
@@ -504,7 +501,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
@@ -512,14 +509,14 @@ public class AgentServiceImpl implements AgentService {
|
||||
@Override
|
||||
public ResponseModel fetchBillByClientReqId(BillFetchByClientIdRequest billFetchByClientIdRequest) {
|
||||
|
||||
String apiName = "FetchBillByClientIdRequest";
|
||||
String apiName = BBPSConstant.API_FETCH_BILL_BY_CLIENT_ID;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = billFetchByClientIdRequest.getReqId();
|
||||
String clientReqId = billFetchByClientIdRequest.getClientReqId();
|
||||
|
||||
Optional<BillInitiate> billInitiate = billIntiateRepository.findByReqId(clientReqId);
|
||||
if (billInitiate.isEmpty()) {
|
||||
throw new CustomException("No Bill Found for given Client Req Id");
|
||||
throw new CustomException(BBPSConstant.NO_BILL_FOUND);
|
||||
}
|
||||
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_VALIDATE_BY_CLIENT_REQ_ID + billInitiate.get().getTxnId();
|
||||
@@ -527,9 +524,9 @@ public class AgentServiceImpl implements AgentService {
|
||||
helper.validateMerchant(billFetchByClientIdRequest.getMid());
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, billFetchByClientIdRequest.getMid(),
|
||||
"GET", null);
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling BBPS API FetchBillByClientReqId, URL={}", fullUrl);
|
||||
@@ -539,11 +536,11 @@ public class AgentServiceImpl implements AgentService {
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
String.valueOf(dataMap.get("remarks")));
|
||||
@@ -558,7 +555,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
@@ -566,26 +563,28 @@ public class AgentServiceImpl implements AgentService {
|
||||
@Override
|
||||
public ResponseModel processBillFetchCallback(BillDataResponse billDataResponse) {
|
||||
LOGGER.info("Recived Call Back from billDataResponse: {}", billDataResponse);
|
||||
if(billDataResponse.getGenericResponse().getStatusCode().equals("200")) { }
|
||||
if(billDataResponse.getGenericResponse().getStatusCode().equals(BBPSConstant.SUCCESS_CODE_STR)) { }
|
||||
else {
|
||||
LOGGER.info("Bill Fetch Callback Failed with Status: {}", billDataResponse.getGenericResponse().getStatus());
|
||||
LOGGER.info("Bill Fetch Callback Failed with Status: {}", billDataResponse.getGenericResponse().getStatus());
|
||||
}
|
||||
return new ResponseModel("CallBack Recieved Successfully",
|
||||
"200",
|
||||
200,
|
||||
"");
|
||||
return new ResponseModel(BBPSConstant.CALLBACK_RECEIVED_SUCCESS,
|
||||
BBPSConstant.SUCCESS_CODE_STR,
|
||||
200,
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel processBillValidateCallback(FetchBillValidateResponse billValidateResponse) {
|
||||
LOGGER.info("Recived Call Back from FetchBillValidateResponse: {}", billValidateResponse);
|
||||
if(billValidateResponse.getGenericResponse().getStatusCode().equals("200")) { }
|
||||
if(billValidateResponse.getGenericResponse().getStatusCode().equals(BBPSConstant.SUCCESS_CODE_STR)) { }
|
||||
else {
|
||||
LOGGER.info("Bill Fetch Callback Failed with Status: {}", billValidateResponse.getGenericResponse().getStatus());
|
||||
LOGGER.info("Bill Fetch Callback Failed with Status: {}", billValidateResponse.getGenericResponse().getStatus());
|
||||
}
|
||||
return new ResponseModel("CallBack Recieved Successfully",
|
||||
"200",
|
||||
200,
|
||||
"");
|
||||
return new ResponseModel(BBPSConstant.CALLBACK_RECEIVED_SUCCESS,
|
||||
BBPSConstant.SUCCESS_CODE_STR,
|
||||
200,
|
||||
""
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user