Merge pull request 'feature3-shared' (#16) from feature3-shared into develop
Reviewed-on: https://git.zeptic.in/himanshu/bbps/pulls/16
This commit is contained in:
+11
-11
@@ -10,15 +10,15 @@ import lombok.Setter;
|
||||
@Getter
|
||||
@Setter
|
||||
public class FetchBillForwardRequest {
|
||||
private String billerId;
|
||||
private String billerName;
|
||||
private String billerCategory;
|
||||
private String clientReqId;
|
||||
private String macAdress;
|
||||
private String customerMobNo;
|
||||
private String remitterName;
|
||||
private String paymentChannel;
|
||||
private List<Tag> deviceBlockTags;
|
||||
private CustomerParamsRequest customerParamsRequest;
|
||||
private List<RemitterIdentity> remitterIdentity;
|
||||
private String billerId;
|
||||
private String billerName;
|
||||
private String billerCategory;
|
||||
private String clientReqId;
|
||||
private String macAdress;
|
||||
private String customerMobNo;
|
||||
private String remitterName;
|
||||
private String paymentChannel;
|
||||
private List<Tag> deviceBlockTags;
|
||||
private CustomerParamsRequest customerParamsRequest;
|
||||
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 com.billpaymentservice.bbps.audit.Auditable;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
@@ -35,7 +36,7 @@ import lombok.ToString;
|
||||
|
||||
@Table(name = "biller_details")
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class BillerDetails {
|
||||
public class BillerDetails{
|
||||
|
||||
@Id
|
||||
@Column(name = "biller_id", length = 14, nullable = false, unique = true)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// java
|
||||
|
||||
package com.billpaymentservice.bbps.serviceImpl;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -60,10 +60,10 @@ public class AgentServiceImpl implements AgentService {
|
||||
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
|
||||
public AgentServiceImpl(RestClient restClient, HttpService httpService, Helper helper,
|
||||
BharatConnectMasterRepository beneficiaryDetailsRepository,
|
||||
InboundTraceLogRepository inboundTraceLogRepository, OutboundTraceLogRepository outboundTraceLogRepository,
|
||||
BillMasterRepository billMasterRepository, BillInitateRepository billIntiateRepository,
|
||||
BillerMapperHelper mapperHelper) {
|
||||
BharatConnectMasterRepository beneficiaryDetailsRepository,
|
||||
InboundTraceLogRepository inboundTraceLogRepository, OutboundTraceLogRepository outboundTraceLogRepository,
|
||||
BillMasterRepository billMasterRepository, BillInitateRepository billIntiateRepository,
|
||||
BillerMapperHelper mapperHelper) {
|
||||
this.restClient = restClient;
|
||||
this.httpService = httpService;
|
||||
this.helper = helper;
|
||||
@@ -75,15 +75,15 @@ public class AgentServiceImpl implements AgentService {
|
||||
|
||||
@Override
|
||||
public ResponseModel initiateBillFetch(FetchBillRequest fetchBillRequest) {
|
||||
LOGGER.info("Initiating bill fetch for request ID: {} and MID :{} and billerId:{} ", fetchBillRequest.getReqId(),
|
||||
fetchBillRequest.getMid(),fetchBillRequest.getBillerId());
|
||||
|
||||
String apiName = BBPSConstant.API_INITIATE_BILL_FETCH;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String requestId = fetchBillRequest.getReqId();
|
||||
String mid = fetchBillRequest.getMid();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, requestId, mid,
|
||||
fetchBillRequest.getBillerId());
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_INTI;
|
||||
fetchBillRequest.setClientReqId(txnId);
|
||||
helper.validateMerchant(fetchBillRequest.getMid());
|
||||
|
||||
FetchBillForwardRequest forwardReq = mapperHelper.fetchBillForwardRequestMap(fetchBillRequest);
|
||||
|
||||
String forwardJson = helper.convertObjectToJson(forwardReq);
|
||||
@@ -91,21 +91,23 @@ public class AgentServiceImpl implements AgentService {
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, fetchBillRequest.getMid(),
|
||||
BBPSConstant.HTTP_POST, requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, fullUrl, BBPSConstant.HTTP_POST,
|
||||
forwardJson);
|
||||
helper.validateMerchant(mid);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_POST, forwardJson);
|
||||
LOGGER.debug("Outbound log created successfully for txnId: {} and reqId: {}", txnId, requestId);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.postRequest(fullUrl, forwardJson, helper.buildHeaders(beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID)));
|
||||
LOGGER.info("[{}] Calling external API | URL={}", apiName, fullUrl);
|
||||
Map<String, String> responseMap = httpService.postRequest(fullUrl, forwardJson,
|
||||
helper.buildHeaders(beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID)));
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
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(BBPSConstant.RESPONSE_GENERIC_KEY)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
LOGGER.warn("Invalid response received for txnId: {}", txnId);
|
||||
@@ -123,7 +125,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
|
||||
FetchBillResponse fetchBillResponse = objectMapper.convertValue(dataMap, FetchBillResponse.class);
|
||||
GeneralResp generalResponse = fetchBillResponse.getGenericResponse();
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResponse.getStatus());
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResponse.getStatus());
|
||||
|
||||
BillInitiate billInitiate = new BillInitiate();
|
||||
billInitiate.setBillId((String) dataMap.get("billId"));
|
||||
@@ -144,6 +146,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
LOGGER.warn("Thread interrupted during delay: {}", e.getMessage());
|
||||
}
|
||||
LOGGER.info("Calling internal method Fetching bill by ID: {}", billFetchByBillIdRequest.getBillId());
|
||||
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResponse.getStatus());
|
||||
return fetchBillById(billFetchByBillIdRequest, inboundLog);
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("JSON Parsing Error: {}", e.getMessage(), e);
|
||||
@@ -160,22 +163,22 @@ public class AgentServiceImpl implements AgentService {
|
||||
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, BBPSConstant.HTTP_GET, null);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET,
|
||||
null);
|
||||
LOGGER.debug("Outbound log created successfully for FetchBillById: {}", fullUrl);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, helper.buildHeaders(beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID)));
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl,
|
||||
helper.buildHeaders(beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID)));
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Bill FetchById Response: {}", responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERIC_KEY)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
@@ -206,71 +209,72 @@ public class AgentServiceImpl implements AgentService {
|
||||
|
||||
@Override
|
||||
public ResponseModel fetchBillById(BillFetchByBillIdRequest billFetchByBillIdRequest) {
|
||||
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();
|
||||
|
||||
LOGGER.info("Initiating {} API for billId={} and reqId={}", apiName, billId, reqId);
|
||||
String apiName = BBPSConstant.API_FETCH_BILL_BY_ID;
|
||||
String reqId = billFetchByBillIdRequest.getReqId();
|
||||
String billId = billFetchByBillIdRequest.getBillId();
|
||||
String mid = billFetchByBillIdRequest.getMid();
|
||||
String requestJson = helper.convertObjectToJson(billFetchByBillIdRequest);
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billId={}", apiName, reqId, mid, billId);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + billFetchByBillIdRequest.getBillId();
|
||||
String txnId = helper.generateTxnId(15);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, billFetchByBillIdRequest.getMid(),
|
||||
BBPSConstant.HTTP_GET, requestJson);
|
||||
LOGGER.info("Initiating {} API for billId={} and reqId={}", apiName, billId, reqId);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET,
|
||||
null);
|
||||
try {
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName,
|
||||
billFetchByBillIdRequest.getMid(), 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(BBPSConstant.ORG_ID)));
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Response received from BBPS for billId={} : {}", billId, responseData);
|
||||
|
||||
try {
|
||||
helper.validateMerchant(billFetchByBillIdRequest.getMid());
|
||||
LOGGER.debug("Merchant validated successfully for MID={}", billFetchByBillIdRequest.getMid());
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
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(BBPSConstant.ORG_ID)));
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Response received from BBPS for billId={} : {}", billId, responseData);
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERIC_KEY)) {
|
||||
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")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
String.valueOf(dataMap.get("remarks")));
|
||||
}
|
||||
BillDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillDataResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
// update inbound log success and persist bill data
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
mapperHelper.saveOrUpdateBillData(responseWrapper, billFetchByBillIdRequest, txnId);
|
||||
LOGGER.info("Bill data saved successfully for billId={} | Status={}", billId, generalResp.getStatus());
|
||||
LOGGER.info("[{}] END | reqId={} | status={}", apiName, reqId, generalResp.getStatus());
|
||||
return responseModel;
|
||||
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERIC_KEY)) {
|
||||
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")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
String.valueOf(dataMap.get("remarks")));
|
||||
}
|
||||
}
|
||||
|
||||
BillDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillDataResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
mapperHelper.saveOrUpdateBillData(responseWrapper, billFetchByBillIdRequest, txnId);
|
||||
LOGGER.info("Bill data saved successfully for billId={} | Status={}", billId, generalResp.getStatus());
|
||||
|
||||
return responseModel;
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON for billId={} : {}", billId, e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON for billId={} : {}", billId, e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel initiateBillValidate(FetchBillValidatestRequest fetchBillValidateRequest) {
|
||||
LOGGER.info("Initiating bill Validate for request ID: {} and MID:{} and billerId:{}", fetchBillValidateRequest.getReqId(),
|
||||
fetchBillValidateRequest.getMid(),fetchBillValidateRequest.getBillerId());
|
||||
|
||||
public ResponseModel initiateBillValidate(FetchBillValidatestRequest fetchBillValidateRequest) {
|
||||
String apiName = BBPSConstant.API_INITIATE_BILL_VALIDATE;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = fetchBillValidateRequest.getReqId();
|
||||
String mid = fetchBillValidateRequest.getMid();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, fetchBillValidateRequest, mid,
|
||||
fetchBillValidateRequest.getBillerId());
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILLER_VALIDATE_URL;
|
||||
fetchBillValidateRequest.setClientReqId(txnId);
|
||||
helper.validateMerchant(fetchBillValidateRequest.getMid());
|
||||
|
||||
FetchBillValidatestForwardRequest forwardReq = mapperHelper
|
||||
.fetchBillValidatestForwardRequest(fetchBillValidateRequest);
|
||||
@@ -281,20 +285,24 @@ public class AgentServiceImpl implements AgentService {
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, fetchBillValidateRequest.getMid(),
|
||||
BBPSConstant.HTTP_POST, requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_POST, forwardJson);
|
||||
helper.validateMerchant(fetchBillValidateRequest.getMid());
|
||||
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 {
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.postRequest(fullUrl, forwardJson, helper.buildHeaders(beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID)));
|
||||
|
||||
LOGGER.info("[{}] Calling external API | URL={}", apiName, fullUrl);
|
||||
Map<String, String> responseMap = httpService.postRequest(fullUrl, forwardJson,
|
||||
helper.buildHeaders(beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID)));
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
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(BBPSConstant.RESPONSE_GENERIC_KEY)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
LOGGER.warn("Invalid response received for txnId: {}", txnId);
|
||||
@@ -311,7 +319,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
LOGGER.info("BillMaster saved for billId: {}", billMaster.getBillId());
|
||||
FetchBillResponse fetchBillResponse = objectMapper.convertValue(dataMap, FetchBillResponse.class);
|
||||
GeneralResp generalResponse = fetchBillResponse.getGenericResponse();
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResponse.getStatus());
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResponse.getStatus());
|
||||
|
||||
BillInitiate billInitiate = new BillInitiate();
|
||||
billInitiate.setBillId((String) dataMap.get("billId"));
|
||||
@@ -332,6 +340,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
LOGGER.warn("Thread interrupted during delay: {}", e.getMessage());
|
||||
}
|
||||
LOGGER.info("Calling internal method Fetching bill by ID: {}", billFetchByBillIdRequest.getBillId());
|
||||
LOGGER.info("[{}] END | reqId={} | status={}", apiName, reqId, generalResponse.getStatus());
|
||||
return BillvaidateByBillId(billFetchByBillIdRequest, inboundLog);
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("JSON Parsing Error: {}", e.getMessage(), e);
|
||||
@@ -350,27 +359,28 @@ public class AgentServiceImpl implements AgentService {
|
||||
String billId = billRequest.getBillId();
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_VALIDATE_ID_URL + billRequest.getBillId();
|
||||
|
||||
helper.validateMerchant(billRequest.getMid());
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.debug("Outbound log created successfully for FetchBillById: {}", fullUrl);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, helper.buildHeaders(beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID)));
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl,
|
||||
helper.buildHeaders(beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID)));
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Bill FetchById Response: {}", responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERIC_KEY)) {
|
||||
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")),
|
||||
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")));
|
||||
}
|
||||
@@ -401,46 +411,54 @@ public class AgentServiceImpl implements AgentService {
|
||||
@Override
|
||||
public ResponseModel initiateBillValidateByBillId(BillFetchByBillIdRequest billRequest) {
|
||||
String apiName = BBPSConstant.API_FETCH_BILL_BY_ID;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = billRequest.getReqId();
|
||||
String billId = billRequest.getBillId();
|
||||
String mid = billRequest.getMid();
|
||||
String requestJson = helper.convertObjectToJson(billRequest);
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billId={}", apiName, billRequest, mid, billId);
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_VALIDATE_ID_URL + billRequest.getBillId();
|
||||
|
||||
LOGGER.info("Initiating {} API for billId={} and reqId={}", apiName, billId, reqId);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, billRequest.getMid(), BBPSConstant.HTTP_GET, null);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, billRequest.getMid(),
|
||||
BBPSConstant.HTTP_GET, requestJson);
|
||||
helper.validateMerchant(billRequest.getMid());
|
||||
try {
|
||||
helper.validateMerchant(billRequest.getMid());
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_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(BBPSConstant.ORG_ID)));
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl,
|
||||
helper.buildHeaders(beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID)));
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Response received from BBPS for billId={} : {}", billId, responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
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(BBPSConstant.RESPONSE_GENERIC_KEY)) {
|
||||
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")),
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
String.valueOf(dataMap.get("remarks")));
|
||||
}
|
||||
|
||||
FetchBillValidateResponse responseWrapper = objectMapper.convertValue(dataMap, FetchBillValidateResponse.class);
|
||||
FetchBillValidateResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||
FetchBillValidateResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
mapperHelper.saveBillValidation(responseWrapper, billRequest);
|
||||
LOGGER.info("Bill validation saved successfully for billId: {}", billId);
|
||||
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(), Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
LOGGER.info("[{}] END | reqId={} | status={}", apiName, reqId, generalResp.getStatus());
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
} catch (com.fasterxml.jackson.core.JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing ValidateByBillId JSON: {}", e.getMessage(), e);
|
||||
@@ -448,41 +466,50 @@ public class AgentServiceImpl implements AgentService {
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
//... remaining methods unchanged except where headers/objectMapper were previously created (they now use buildHeaders() and the class-level objectMapper)
|
||||
// ================================== Bill fetch and Bill Validate by Client Req
|
||||
// Id==================================//
|
||||
// =======
|
||||
|
||||
// ... remaining methods unchanged except where headers/objectMapper were
|
||||
// previously created (they now use buildHeaders() and the class-level
|
||||
// objectMapper)
|
||||
// >>>>>>>d0812656ff2aee80b1eb0c0ab8e29a01d7d66553
|
||||
|
||||
@Override
|
||||
public ResponseModel fetchBillValidateByClientReqId(BillValidateByClientIdRequest billValidateByClientIdRequest) {
|
||||
|
||||
String apiName = BBPSConstant.API_FETCH_BILL_VALIDATE_BY_CLIENT_ID;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = billValidateByClientIdRequest.getReqId();
|
||||
String clientReqId = billValidateByClientIdRequest.getClientReqId();
|
||||
String mid = billValidateByClientIdRequest.getMid();
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String requestJson = helper.convertObjectToJson(billValidateByClientIdRequest);
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | clientReqId={}", apiName, reqId, mid,
|
||||
billValidateByClientIdRequest.getClientReqId());
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName,
|
||||
billValidateByClientIdRequest.getMid(), BBPSConstant.HTTP_GET,requestJson);
|
||||
|
||||
helper.validateMerchant(billValidateByClientIdRequest.getMid());
|
||||
Optional<BillInitiate> billInitiate = billIntiateRepository.findByReqId(clientReqId);
|
||||
if (billInitiate.isEmpty()) {
|
||||
throw new CustomException(BBPSConstant.NO_BILL_FOUND);
|
||||
}
|
||||
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_VALIDATE_BY_CLIENT_REQ_ID + billInitiate.get().getTxnId();
|
||||
|
||||
helper.validateMerchant(billValidateByClientIdRequest.getMid());
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName,
|
||||
billValidateByClientIdRequest.getMid(), BBPSConstant.HTTP_GET, null);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET,
|
||||
null);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling BBPS API FetchBillValidateByClientReqId, URL={}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, helper.buildHeaders(beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID)));
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl,
|
||||
helper.buildHeaders(beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID)));
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERIC_KEY)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
@@ -496,7 +523,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
|
||||
LOGGER.info("[{}] END | reqId={} | status={}", apiName, reqId, generalResp.getStatus());
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
@@ -510,34 +537,37 @@ public class AgentServiceImpl implements AgentService {
|
||||
public ResponseModel fetchBillByClientReqId(BillFetchByClientIdRequest billFetchByClientIdRequest) {
|
||||
|
||||
String apiName = BBPSConstant.API_FETCH_BILL_BY_CLIENT_ID;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = billFetchByClientIdRequest.getReqId();
|
||||
String clientReqId = billFetchByClientIdRequest.getClientReqId();
|
||||
String mid = billFetchByClientIdRequest.getMid();
|
||||
String requestJson = helper.convertObjectToJson(billFetchByClientIdRequest);
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | clientReqId={}", apiName, reqId, mid,
|
||||
billFetchByClientIdRequest.getClientReqId());
|
||||
String txnId = helper.generateTxnId(15);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, billFetchByClientIdRequest.getMid(),
|
||||
BBPSConstant.HTTP_GET, requestJson);
|
||||
helper.validateMerchant(billFetchByClientIdRequest.getMid());
|
||||
|
||||
Optional<BillInitiate> billInitiate = billIntiateRepository.findByReqId(clientReqId);
|
||||
if (billInitiate.isEmpty()) {
|
||||
throw new CustomException(BBPSConstant.NO_BILL_FOUND);
|
||||
}
|
||||
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_VALIDATE_BY_CLIENT_REQ_ID + billInitiate.get().getTxnId();
|
||||
|
||||
helper.validateMerchant(billFetchByClientIdRequest.getMid());
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, billFetchByClientIdRequest.getMid(),
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET,
|
||||
null);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling BBPS API FetchBillByClientReqId, URL={}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, helper.buildHeaders(beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID)));
|
||||
LOGGER.info("[{}] Calling external API | URL={} | reqId={}", apiName, fullUrl, reqId);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl,
|
||||
helper.buildHeaders(beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID)));
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERIC_KEY)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
@@ -550,7 +580,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
|
||||
LOGGER.info("[{}] END | reqId={} | status={}", apiName, reqId, generalResp.getStatus());
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
@@ -560,31 +590,214 @@ public class AgentServiceImpl implements AgentService {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @Override public ResponseModel
|
||||
* initiateBillValidate(FetchBillValidatestRequest fetchBillValidateRequest) {
|
||||
*
|
||||
* ResponseModel responseModel = new ResponseModel(); try {
|
||||
*
|
||||
* helper.validateMerchant(fetchBillValidateRequest.getMid());
|
||||
*
|
||||
* BharatConnectMaster headersData =
|
||||
* beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
*
|
||||
* if (headersData == null) { responseModel = new
|
||||
* ResponseModel("Tenant Id Is Null", "Not Found", BBPSConstant.BADREQUEST,
|
||||
* headersData); return responseModel; }
|
||||
*
|
||||
* HttpHeaders headers = new HttpHeaders(); headers.set("x-digiledge-key",
|
||||
* headersData.getXDigiledgeKey()); headers.set("agentId",
|
||||
* headersData.getAgentId()); headers.set("tenantId",
|
||||
* headersData.getTenantId());
|
||||
* headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
*
|
||||
* ObjectMapper objectMapper = new ObjectMapper();
|
||||
* objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); String
|
||||
* json = objectMapper.writeValueAsString(fetchBillValidateRequest); String url
|
||||
* = agentDtaUrl + BBPSConstant.BILLER_VALIDATE_URL;
|
||||
*
|
||||
* Map<String, String> responseMap = httpService.postRequest(url, json,
|
||||
* headers); String responseData = responseMap.get("data");
|
||||
*
|
||||
* log.info("📦 Bill Fetch API Response: {}", responseData);
|
||||
*
|
||||
* if (responseData == null || responseData.isEmpty()) { throw new
|
||||
* CustomException("Empty response from BBPS server"); }
|
||||
*
|
||||
* // ✅ Convert JSON string → Map Map<String, Object> dataMap =
|
||||
* objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>()
|
||||
* {});
|
||||
*
|
||||
* // ✅ Validate generalResp if (!dataMap.containsKey("genericResponse")) {
|
||||
* throw new CustomException("Invalid response structure from BBPS"); }
|
||||
*
|
||||
* // ✅ Convert to your custom DTO FetchBillValidatestResponse fetchBillResponse
|
||||
* = objectMapper.convertValue(dataMap, FetchBillValidatestResponse.class);
|
||||
* GeneralResp generalResponse = fetchBillResponse.getGenericResponse();
|
||||
*
|
||||
* // ✅ Build final ResponseModel responseModel = new ResponseModel(
|
||||
* generalResponse.getMessage(), generalResponse.getStatus(),
|
||||
* Integer.parseInt(generalResponse.getStatusCode()), fetchBillResponse );
|
||||
*
|
||||
* } catch (CustomException ex) { log.warn("Merchant validation failed: {}",
|
||||
* ex.getMessage()); return ex.getResponseModel(); // Directly return
|
||||
* ResponseModel from exception } catch (Exception e) {
|
||||
* log.error("❌ Exception in initiateBillFetch(): {}", e.getMessage(), e);
|
||||
* responseModel.setStatus("500");
|
||||
* responseModel.setMessage("Exception occurred");
|
||||
* responseModel.setData(e.getMessage()); }
|
||||
*
|
||||
* return responseModel; }
|
||||
*
|
||||
* @Override public ResponseModel
|
||||
* initiateBillValidateByBillId(BillFetchByBillIdRequest billRequest) {
|
||||
*
|
||||
* ResponseModel responseModel = new ResponseModel(); try {
|
||||
* helper.validateMerchant(billRequest.getMid());
|
||||
*
|
||||
* BharatConnectMaster headersData =
|
||||
* beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
*
|
||||
* if (headersData == null) { responseModel = new
|
||||
* ResponseModel("Tenant Id Is Null", "Not Found", BBPSConstant.BADREQUEST,
|
||||
* headersData); return responseModel; }
|
||||
*
|
||||
* HttpHeaders headers = new HttpHeaders(); headers.set("x-digiledge-key",
|
||||
* headersData.getXDigiledgeKey()); headers.set("agentId",
|
||||
* headersData.getAgentId()); headers.set("tenantId",
|
||||
* headersData.getTenantId());
|
||||
* headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
*
|
||||
* ObjectMapper objectMapper = new ObjectMapper();
|
||||
* objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); String
|
||||
* json = objectMapper.writeValueAsString(billRequest); String url = agentDtaUrl
|
||||
* + BBPSConstant.BILL_ID_URL + billRequest.getBillId();
|
||||
*
|
||||
* log.info("Full URL: {}", url);
|
||||
* objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
*
|
||||
* // ✅ Call the API using httpService Map<String, String> responseMap =
|
||||
* httpService.getRequest(url, headers); String responseData =
|
||||
* responseMap.get("data");
|
||||
*
|
||||
* log.info("📦 Bill Fetch API Response: {}", responseData);
|
||||
*
|
||||
* if (responseData == null || responseData.isEmpty()) { throw new
|
||||
* CustomException("Empty response from BBPS server"); }
|
||||
*
|
||||
* // ✅ Convert JSON string → Map Map<String, Object> dataMap =
|
||||
* objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>()
|
||||
* {});
|
||||
*
|
||||
* // ✅ Validate generalResp if (!dataMap.containsKey("genericResponse")) {
|
||||
* throw new CustomException("Invalid response structure from BBPS"); }
|
||||
*
|
||||
* // ✅ Convert to your custom DTO BillDataResponse fetchBillResponse =
|
||||
* objectMapper.convertValue(dataMap, BillDataResponse.class); GeneralResp
|
||||
* generalResponse = fetchBillResponse.getGenericResponse();
|
||||
*
|
||||
* // ✅ Build final ResponseModel responseModel = new ResponseModel(
|
||||
* generalResponse.getRemarks(), generalResponse.getStatus(),
|
||||
* Integer.parseInt(generalResponse.getStatusCode()), fetchBillResponse );
|
||||
*
|
||||
* } catch (CustomException ex) { log.warn("Merchant validation failed: {}",
|
||||
* ex.getMessage()); return ex.getResponseModel(); // Directly return
|
||||
* ResponseModel from exception } catch (Exception e) {
|
||||
* log.error("❌ Exception in initiateBillFetch(): {}", e.getMessage(), e);
|
||||
* responseModel.setStatus("500");
|
||||
* responseModel.setMessage("Exception occurred");
|
||||
* responseModel.setData(e.getMessage()); }
|
||||
*
|
||||
* return responseModel; }
|
||||
*/
|
||||
|
||||
/*
|
||||
* POLLING METHOD public ResponseModel fetchBillById(BillFetchByBillIdRequest
|
||||
* billFetchByBillIdRequest, InboundTraceLog inboundLog) { String apiName =
|
||||
* "FetchBillById"; String txnId = helper.generateTxnId(15); String reqId =
|
||||
* billFetchByBillIdRequest.getReqId(); String billId =
|
||||
* billFetchByBillIdRequest.getBillId(); String url = agentDtaUrl +
|
||||
* BBPSConstant.BILL_FETCH_BY_ID + "1ced7566-1add-4e01-9ed6-04cd67ac9684";
|
||||
*
|
||||
* helper.validateMerchant(billFetchByBillIdRequest.getMid());
|
||||
*
|
||||
* BharatConnectMaster headersData =
|
||||
* beneficiaryDetailsRepository.findByOrgId("ORG001"); HttpHeaders headers = new
|
||||
* HttpHeaders(); headers.set("x-digiledge-key",
|
||||
* headersData.getXDigiledgeKey()); headers.set("agentId",
|
||||
* headersData.getAgentId()); headers.set("tenantId",
|
||||
* headersData.getTenantId());
|
||||
* headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
*
|
||||
* ObjectMapper objectMapper = new ObjectMapper(); OutboundTraceLog outboundLog
|
||||
* = helper.createOutboundLog(txnId, reqId, apiName, url, "GET", null);
|
||||
*
|
||||
* // ✅ Loop setup long startTime = System.currentTimeMillis(); long
|
||||
* maxWaitTimeMs = 40000; // 40 seconds long intervalMs = 5000; // 5 seconds
|
||||
*
|
||||
* while (true) { try { Map<String, String> responseMap =
|
||||
* httpService.getRequest(url, headers); String responseData =
|
||||
* responseMap.get("data"); log.info("📦 Bill FetchById Response: {}",
|
||||
* responseData);
|
||||
*
|
||||
* helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
*
|
||||
* Map<String, Object> dataMap = objectMapper.readValue(responseData, new
|
||||
* TypeReference<Map<String, Object>>() {});
|
||||
*
|
||||
* if (!dataMap.containsKey("genericResponse")) {
|
||||
* helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
* throw new CustomException( String.valueOf(dataMap.get("message")),
|
||||
* String.valueOf(dataMap.get("status")),
|
||||
* Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
* String.valueOf(dataMap.get("remarks")) ); }
|
||||
*
|
||||
* BillDataResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||
* BillDataResponse.class); GeneralResp generalResp =
|
||||
* responseWrapper.getGenericResponse();
|
||||
*
|
||||
* String status = generalResp.getStatus();
|
||||
* log.info("📡 Current Bill Status: {}", status); // ✅ Check for "INPROGRESS"
|
||||
* or pending state if ("INPROGRESS".equalsIgnoreCase(status)) { if
|
||||
* (System.currentTimeMillis() - startTime > maxWaitTimeMs) {
|
||||
* helper.updateInboundLogFailure(inboundLog, "Timeout after 40 seconds",
|
||||
* "FAILED"); throw new CustomException("Timeout", "FAILED", 408,
|
||||
* "Bill fetch still in progress"); } Thread.sleep(intervalMs); continue; //
|
||||
* retry again } // ✅ Final successful response
|
||||
* helper.updateInboundLogSuccess(inboundLog, responseData,
|
||||
* generalResp.getStatus()); return new ResponseModel( generalResp.getMessage(),
|
||||
* generalResp.getStatus(), Integer.parseInt(generalResp.getStatusCode()),
|
||||
* responseWrapper ); } catch (JsonProcessingException e) {
|
||||
* log.error("Error parsing BillById JSON: {}", e.getMessage());
|
||||
* helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
* throw new CustomException("Invalid JSON received from API"); } catch
|
||||
* (InterruptedException e) { Thread.currentThread().interrupt();
|
||||
* helper.updateInboundLogFailure(inboundLog, e.getMessage(), "INTERRUPTED");
|
||||
* throw new CustomException("Thread interrupted during bill status check"); } }
|
||||
* }
|
||||
*/
|
||||
|
||||
@Override
|
||||
public ResponseModel processBillFetchCallback(BillDataResponse billDataResponse) {
|
||||
LOGGER.info("Recived Call Back from billDataResponse: {}", billDataResponse);
|
||||
if(billDataResponse.getGenericResponse().getStatusCode().equals(BBPSConstant.SUCCESS_CODE_STR)) { }
|
||||
else {
|
||||
LOGGER.info("Bill Fetch Callback Failed with Status: {}", billDataResponse.getGenericResponse().getStatus());
|
||||
}
|
||||
return new ResponseModel(BBPSConstant.CALLBACK_RECEIVED_SUCCESS,
|
||||
BBPSConstant.SUCCESS_CODE_STR,
|
||||
BBPSConstant.HTTP_OK_INT,
|
||||
""
|
||||
);
|
||||
if (billDataResponse.getGenericResponse().getStatusCode().equals(BBPSConstant.SUCCESS_CODE_STR)) {
|
||||
} else {
|
||||
LOGGER.info("Bill Fetch Callback Failed with Status: {}",
|
||||
billDataResponse.getGenericResponse().getStatus());
|
||||
}
|
||||
return new ResponseModel(BBPSConstant.CALLBACK_RECEIVED_SUCCESS, BBPSConstant.SUCCESS_CODE_STR,
|
||||
BBPSConstant.HTTP_OK_INT, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel processBillValidateCallback(FetchBillValidateResponse billValidateResponse) {
|
||||
LOGGER.info("Recived Call Back from FetchBillValidateResponse: {}", billValidateResponse);
|
||||
if(billValidateResponse.getGenericResponse().getStatusCode().equals(BBPSConstant.SUCCESS_CODE_STR)) { }
|
||||
else {
|
||||
LOGGER.info("Bill Fetch Callback Failed with Status: {}", billValidateResponse.getGenericResponse().getStatus());
|
||||
}
|
||||
return new ResponseModel(BBPSConstant.CALLBACK_RECEIVED_SUCCESS,
|
||||
BBPSConstant.SUCCESS_CODE_STR,
|
||||
BBPSConstant.HTTP_OK_INT,
|
||||
""
|
||||
);
|
||||
if (billValidateResponse.getGenericResponse().getStatusCode().equals(BBPSConstant.SUCCESS_CODE_STR)) {
|
||||
} else {
|
||||
LOGGER.info("Bill Fetch Callback Failed with Status: {}",
|
||||
billValidateResponse.getGenericResponse().getStatus());
|
||||
}
|
||||
return new ResponseModel(BBPSConstant.CALLBACK_RECEIVED_SUCCESS, BBPSConstant.SUCCESS_CODE_STR,
|
||||
BBPSConstant.HTTP_OK_INT, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ import com.billpaymentservice.bbps.dto.response.TicketCheckStatusResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.TxnStatusResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.ViewAllComplaintsTicketsResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.ViewComplainByIdResponse;
|
||||
import com.billpaymentservice.bbps.dto.sentRequest.FetchComplaintForwardRequest;
|
||||
import com.billpaymentservice.bbps.dto.sentRequest.FetchTicketLatestStatusRequest;
|
||||
import com.billpaymentservice.bbps.entites.BharatConnectMaster;
|
||||
import com.billpaymentservice.bbps.entites.ComplaintStatusOptionsMaster;
|
||||
import com.billpaymentservice.bbps.entites.InboundTraceLog;
|
||||
@@ -84,42 +86,43 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
@Override
|
||||
public ResponseModel addComplain(ComplaintRequestDTO complainRequestDTO) {
|
||||
|
||||
LOGGER.info("Initiating add Complain for request ID: {} and MID {}", complainRequestDTO.getReqId(),
|
||||
complainRequestDTO.getMid());
|
||||
|
||||
String apiName = BBPSConstant.API_ADD_COMPLAIN;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String requestId = complainRequestDTO.getReqId();
|
||||
String mid = complainRequestDTO.getMid();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={}", apiName, requestId, mid);
|
||||
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String fullUrl = complainDataUrl + BBPSConstant.ADD_COMPLAIN_ENDPOINT;
|
||||
|
||||
LOGGER.info("Full URL-: "+ fullUrl);
|
||||
|
||||
// Convert input DTO to JSON
|
||||
String requestJson = helper.convertObjectToJson(complainRequestDTO);
|
||||
|
||||
LOGGER.info("[{}] Full URL={}", apiName, fullUrl);
|
||||
// Fetch tenant & agent from DB
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
|
||||
FetchComplaintForwardRequest forwardReq = mapperHelper.fetchComplaintForwardRequestMap(complainRequestDTO);
|
||||
String forwardJson = helper.convertObjectToJson(forwardReq);
|
||||
String requestJson = helper.convertObjectToJson(complainRequestDTO);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, complainRequestDTO.getMid(),
|
||||
BBPSConstant.HTTP_POST, requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, fullUrl, BBPSConstant.HTTP_POST, null);
|
||||
helper.validateMerchant(mid);
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_POST, null);
|
||||
|
||||
try {
|
||||
// Inject tenantId + agentId into request JSON
|
||||
ObjectNode root = (ObjectNode) objectMapper.readTree(requestJson);
|
||||
ObjectNode root = (ObjectNode) objectMapper.readTree(forwardJson);
|
||||
root.put("tenantId", headersData.getTenantId());
|
||||
root.put("agentId", headersData.getAgentId());
|
||||
|
||||
String finalJson = root.toString();
|
||||
LOGGER.info("Final Request Sent to API: {}", finalJson);
|
||||
LOGGER.info("[{}] Final Request Sent to API | reqId={} | payload={}", apiName, requestId, finalJson);
|
||||
|
||||
// IMPORTANT: Send finalJson, not requestJson
|
||||
Map<String, String> responseMap = httpService.postRequest(fullUrl, finalJson, headers);
|
||||
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Fetched response: {}", responseData);
|
||||
LOGGER.debug("[{}] Response Received | reqId={} | data={}", apiName, requestId, responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
@@ -130,7 +133,7 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
if (start != -1 && end != -1) {
|
||||
responseData = responseData.substring(start, end + 1);
|
||||
}
|
||||
LOGGER.info("Extracted pure JSON from error: {}", responseData);
|
||||
LOGGER.warn("[{}] Extracted JSON from error wrapper | data={}", apiName, responseData);
|
||||
}
|
||||
|
||||
// Parse JSON into Map
|
||||
@@ -138,10 +141,11 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
int statusCode = Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY)));
|
||||
int statusCode = Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY)));
|
||||
|
||||
// Throw exception for non-200
|
||||
if (statusCode != BBPSConstant.HTTP_OK_INT) {
|
||||
LOGGER.warn("[{}] Failure Response | reqId={} | statusCode={}", apiName, requestId, statusCode);
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)),
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), statusCode,
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
|
||||
@@ -154,6 +158,7 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
Integer.parseInt(responseWrapper.getStatusCode()), responseWrapper);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, responseWrapper.getStatus());
|
||||
LOGGER.info("[{}] SUCCESS | reqId={} | status={}", apiName, requestId, responseWrapper.getStatus());
|
||||
return responseModel;
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
@@ -166,42 +171,45 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
@Override
|
||||
public ResponseModel getComplaintStatus(GetTicketLatestStausRequest request) {
|
||||
|
||||
LOGGER.info("Fetching Complaint Status for TicketId={} ReqId={}", request.getTicketId(), request.getReqId());
|
||||
|
||||
String apiName = BBPSConstant.API_COMPLAINT_STATUS;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = request.getReqId();
|
||||
String complaintId = request.getTicketId();
|
||||
String mid = request.getMid();
|
||||
String ticketId = request.getTicketId();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | ticketId={}", apiName, reqId, mid, ticketId);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.COMPALINT_STATUS;
|
||||
|
||||
helper.validateMerchant(request.getMid());
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
|
||||
// Convert request to JSON
|
||||
String txnId = helper.generateTxnId(15);
|
||||
FetchTicketLatestStatusRequest forwardReq = mapperHelper.fetchTicketLatestStatusRequestMap(request);
|
||||
String forwardJson = helper.convertObjectToJson(forwardReq);
|
||||
String requestJson = helper.convertObjectToJson(request);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), BBPSConstant.HTTP_POST,
|
||||
requestJson);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_POST, complaintId);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(),
|
||||
BBPSConstant.HTTP_POST, requestJson);
|
||||
helper.validateMerchant(request.getMid());
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
// Convert request to JSON
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_POST,
|
||||
complaintId);
|
||||
|
||||
try {
|
||||
|
||||
ObjectNode root = (ObjectNode) objectMapper.readTree(requestJson);
|
||||
ObjectNode root = (ObjectNode) objectMapper.readTree(forwardJson);
|
||||
root.put("tenantId", headersData.getTenantId());
|
||||
//root.put("agentId", headersData.getAgentId());
|
||||
// root.put("agentId", headersData.getAgentId());
|
||||
|
||||
String finalJson = root.toString();
|
||||
LOGGER.info("Final Request Sent to API: {}", finalJson);
|
||||
// LOGGER.info("Calling external API: {}", fullUrl);
|
||||
LOGGER.info("[{}] Final API Payload | reqId={} | payload={}", apiName, reqId, finalJson);
|
||||
|
||||
Map<String, String> responseMap = httpService.postRequest(fullUrl, finalJson, headers);
|
||||
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
|
||||
LOGGER.info("Complaint Fetch Response: {}", responseData);
|
||||
LOGGER.debug("[{}] Raw Response | reqId={} | data={}", apiName, reqId, responseData);
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
// Handle HttpService error wrapper
|
||||
@@ -219,16 +227,18 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
int statusCode = Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY)));
|
||||
|
||||
int statusCode = Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY)));
|
||||
if (statusCode != BBPSConstant.HTTP_OK_INT) {
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)),
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), statusCode,
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
|
||||
}
|
||||
|
||||
TicketCheckStatusResponse responseWrapper = objectMapper.convertValue(dataMap, TicketCheckStatusResponse.class);
|
||||
TicketCheckStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||
TicketCheckStatusResponse.class);
|
||||
|
||||
String saveComplaintStatus = mapperHelper.saveComplaintStatus(responseWrapper, reqId, txnId);
|
||||
LOGGER.info("[{}] Save Status | ticketId={} | status={}", apiName, ticketId, saveComplaintStatus);
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, responseWrapper.getStatus());
|
||||
|
||||
return new ResponseModel(responseWrapper.getMessage(), responseWrapper.getStatus(),
|
||||
@@ -243,31 +253,32 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
|
||||
@Override
|
||||
public ResponseModel viewComplaintHistory(ComplainStatusRequest request) {
|
||||
LOGGER.info("Fetching View Complaint History Complaint by Complaint Id={}", request.getTicketId(),
|
||||
request.getReqId());
|
||||
|
||||
String apiName = BBPSConstant.API_VIEW_COMPLAINT_HISTORY;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = request.getReqId();
|
||||
String ticketId = request.getTicketId();
|
||||
String mid = request.getMid();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | ticketId={}", apiName, reqId, mid, ticketId);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.COMPLAINT_HISTORY + request.getTicketId();
|
||||
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String requestJson = helper.convertObjectToJson(request);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(),
|
||||
BBPSConstant.HTTP_GET, requestJson);
|
||||
helper.validateMerchant(request.getMid());
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
|
||||
String requestJson = helper.convertObjectToJson(request);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), BBPSConstant.HTTP_GET,
|
||||
requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET, ticketId);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET,
|
||||
ticketId);
|
||||
LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
LOGGER.info("[{}] Calling external API | URL={} | reqId={}", apiName, fullUrl, reqId);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Complaint History Complaint FetchById Response: {}", responseData);
|
||||
LOGGER.debug("[{}] Raw Response | reqId={} | data={}", apiName, reqId, responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
@@ -275,12 +286,15 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
LOGGER.warn("[{}] Invalid response structure | reqId={} | data={}", apiName, reqId, responseData);
|
||||
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
LOGGER.warn("Invalid response structure for txnId: {}", txnId);
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)),
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)),
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), String.valueOf(""));
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))),
|
||||
String.valueOf(""));
|
||||
}
|
||||
|
||||
ComplaintHistoryStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||
@@ -292,8 +306,8 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
String saveComplaintHistory = mapperHelper.saveComplaintHistory(responseWrapper, reqId, txnId);
|
||||
LOGGER.info("Complaint ReOpen data saved successfully for Count History: {}", saveComplaintHistory);
|
||||
|
||||
LOGGER.info("[{}] Complaint history saved | ticketId={} | entryId={}", apiName, ticketId,
|
||||
saveComplaintHistory);
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
} catch (JsonProcessingException e) {
|
||||
@@ -306,27 +320,27 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
@Override
|
||||
public ResponseModel viewComplaintById(ComplainStatusRequest request) {
|
||||
|
||||
LOGGER.info("Fetching View Complaint Complaint by Complaint Id={}", request.getTicketId(), request.getReqId());
|
||||
String apiName = BBPSConstant.API_VIEW_COMPLAINT_BY_ID;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = request.getReqId();
|
||||
String ticketId = request.getTicketId();
|
||||
String mid = request.getMid();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | ticketId={}", apiName, reqId, mid, ticketId);
|
||||
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.VIEW_COMPLAINT_BY_ID + request.getTicketId();
|
||||
|
||||
String requestJson = helper.convertObjectToJson(request);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(),
|
||||
BBPSConstant.HTTP_GET, requestJson);
|
||||
helper.validateMerchant(request.getMid());
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
|
||||
String requestJson = helper.convertObjectToJson(request);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), BBPSConstant.HTTP_GET,
|
||||
requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET, ticketId);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET,
|
||||
ticketId);
|
||||
LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
LOGGER.info("[{}] Calling external API | reqId={} | URL={}", apiName, reqId, fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Complaint History Complaint FetchById Response: {}", responseData);
|
||||
@@ -337,12 +351,13 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
LOGGER.warn("Invalid response structure for txnId: {}", txnId);
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)),
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)),
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), String.valueOf(""));
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))),
|
||||
String.valueOf(""));
|
||||
}
|
||||
|
||||
ViewComplainByIdResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||
@@ -354,7 +369,7 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
String saveComplaint = mapperHelper.saveComplainStatusDetail(responseWrapper, reqId, txnId);
|
||||
LOGGER.info("Complaint ReOpen data saved successfully for Count History: {}", saveComplaint);
|
||||
LOGGER.info("[{}] Complaint details saved | ticketId={} | id={}", apiName, ticketId, saveComplaint);
|
||||
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
@@ -369,6 +384,7 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
public ResponseModel getAllActiveStatuses(AllMasterOptionsRequest request) {
|
||||
|
||||
try {
|
||||
|
||||
LOGGER.info("Fetch All Master Options - MID: {}", request.getMid());
|
||||
String apiName = BBPSConstant.API_GET_ALL_MASTER_OPTIONS;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
@@ -376,11 +392,12 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
String fullUrl = BBPSConstant.DB_OPTIONS;
|
||||
|
||||
String requestJson = helper.convertObjectToJson(request);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(),
|
||||
BBPSConstant.HTTP_GET, requestJson);
|
||||
// Validate merchant
|
||||
helper.validateMerchant(request.getMid());
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), BBPSConstant.HTTP_GET,
|
||||
requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
|
||||
|
||||
// Fetch data from DB
|
||||
@@ -391,15 +408,17 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
|
||||
// Check empty or null
|
||||
if (allActiveStatuses == null || allActiveStatuses.isEmpty()) {
|
||||
helper.updateInboundLogFailure(inboundLog, String.valueOf(allActiveStatuses), BBPSConstant.NULL_DATA_FROM_DB);
|
||||
helper.updateInboundLogFailure(inboundLog, String.valueOf(allActiveStatuses),
|
||||
BBPSConstant.NULL_DATA_FROM_DB);
|
||||
return new ResponseModel(BBPSConstant.NO_MASTER_FIELDS_FOUND, BBPSConstant.FAILED_STATUS,
|
||||
BBPSConstant.HTTP_NOT_FOUND, null, 0);
|
||||
BBPSConstant.HTTP_NOT_FOUND, null, 0);
|
||||
}
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, String.valueOf(allActiveStatuses), String.valueOf(BBPSConstant.HTTP_OK_INT));
|
||||
helper.updateInboundLogSuccess(inboundLog, String.valueOf(allActiveStatuses),
|
||||
String.valueOf(BBPSConstant.HTTP_OK_INT));
|
||||
// SUCCESS RESPONSE
|
||||
return new ResponseModel(BBPSConstant.ALL_MASTER_FIELDS_FETCH, BBPSConstant.SUCCESS_RESPONSE, BBPSConstant.HTTP_OK_INT, allActiveStatuses,
|
||||
allActiveStatuses.size());
|
||||
return new ResponseModel(BBPSConstant.ALL_MASTER_FIELDS_FETCH, BBPSConstant.SUCCESS_RESPONSE,
|
||||
BBPSConstant.HTTP_OK_INT, allActiveStatuses, allActiveStatuses.size());
|
||||
|
||||
}
|
||||
|
||||
@@ -412,27 +431,31 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
}
|
||||
|
||||
public ResponseModel checkTxnStatus(TxnStatusRequest request) {
|
||||
LOGGER.info("Check Txn Status Request by Id={} and ReqId ={}", request.getId(), request.getReqId());
|
||||
|
||||
String apiName = BBPSConstant.API_CHECK_TXN_STATUS;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = request.getReqId();
|
||||
String ID = request.getId();
|
||||
String mid = request.getMid();
|
||||
String transactionId = request.getId();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | txnId={}", apiName, reqId, mid, transactionId);
|
||||
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.CHECK_TRANSACTION_URL + request.getId();
|
||||
|
||||
String requestJson = helper.convertObjectToJson(request);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(),
|
||||
BBPSConstant.HTTP_GET, requestJson);
|
||||
helper.validateMerchant(request.getMid());
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
|
||||
String requestJson = helper.convertObjectToJson(request);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), BBPSConstant.HTTP_GET,
|
||||
requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET, ID);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET,
|
||||
ID);
|
||||
LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
LOGGER.info("[{}] Calling external BBPS API | URL={}", apiName, fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("checkTxnStatus: {}", responseData);
|
||||
@@ -443,12 +466,13 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
LOGGER.warn("Invalid response structure for txnId: {}", txnId);
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)),
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)),
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), String.valueOf(""));
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))),
|
||||
String.valueOf(""));
|
||||
}
|
||||
|
||||
TxnStatusResponse responseWrapper = objectMapper.convertValue(dataMap, TxnStatusResponse.class);
|
||||
@@ -458,6 +482,7 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
LOGGER.info("Current Complaint ReOpen Status: {}", status);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
LOGGER.info("[{}] End Txn Status: {}", apiName, generalResp.getStatus());
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
} catch (JsonProcessingException e) {
|
||||
@@ -471,31 +496,31 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
@Override
|
||||
public ResponseModel ViewAllComplaints(ViewAllComplaintsTicketsRequest request) {
|
||||
|
||||
LOGGER.info("Fetching All Complaint for status Type={} and reqId={} ", request.getStatusType(),
|
||||
request.getReqId());
|
||||
String apiName = BBPSConstant.API_VIEW_ALL_COMPLAINTS_BY_STATUS;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = request.getReqId();
|
||||
String mid = request.getMid();
|
||||
String statusType = request.getStatusType();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | statusType={}", apiName, reqId, mid, statusType);
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String fullUrl = complainDataUrl + BBPSConstant.VIEW_ALL_COMPLAINTS_BASE + "?pageNo=" + request.getPageNo()
|
||||
+ "&pageSize=" + request.getPageSize() + "&statusType=" + request.getStatusType() + "&ticketType="
|
||||
+ request.getTicketType();
|
||||
|
||||
helper.validateMerchant(request.getMid());
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
+ "&pageSize=" + request.getPageSize() + "&statusType=" + request.getStatusType() + "&ticketType="
|
||||
+ request.getTicketType();
|
||||
|
||||
String requestJson = helper.convertObjectToJson(request);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), BBPSConstant.HTTP_POST,
|
||||
requestJson);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(),
|
||||
BBPSConstant.HTTP_POST, requestJson);
|
||||
helper.validateMerchant(request.getMid());
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET,
|
||||
request.getStatusType());
|
||||
request.getStatusType());
|
||||
LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
LOGGER.info("[{}] Calling external API | URL={}", apiName, fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Response: {}", responseData);
|
||||
|
||||
@@ -505,12 +530,13 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
LOGGER.warn("Invalid response structure for txnId: {}", txnId);
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)),
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)),
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), String.valueOf(""));
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))),
|
||||
String.valueOf(""));
|
||||
}
|
||||
|
||||
ViewAllComplaintsTicketsResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||
@@ -521,7 +547,7 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
LOGGER.info("Current Complaint ReOpen Status: {}", status);
|
||||
|
||||
String saveComplaint = mapperHelper.saveAllComplaints(responseWrapper, reqId, txnId);
|
||||
LOGGER.info("Complaint ReOpen data saved successfully for Count History: {}", saveComplaint);
|
||||
LOGGER.info("[{}] Complaint records saved into DB | count={}", apiName, saveComplaint);
|
||||
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
+233
-148
@@ -41,6 +41,7 @@ import com.billpaymentservice.bbps.entites.CustomParam;
|
||||
import com.billpaymentservice.bbps.entites.DispositionDetails;
|
||||
import com.billpaymentservice.bbps.entites.InboundTraceLog;
|
||||
import com.billpaymentservice.bbps.entites.OutboundTraceLog;
|
||||
import com.billpaymentservice.bbps.entites.PlanResponses;
|
||||
import com.billpaymentservice.bbps.exception.CustomException;
|
||||
import com.billpaymentservice.bbps.repository.BharatConnectMasterRepository;
|
||||
import com.billpaymentservice.bbps.repository.BillerDataRepository;
|
||||
@@ -103,16 +104,18 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
@Override
|
||||
public ResponseModel getMasterData(MasterRequest masterRequest) {
|
||||
LOGGER.info("Fetching Master Data for ReqId={} and MID={}", masterRequest.getReqId(), masterRequest.getMid());
|
||||
String txnID = helper.generateTxnId(15);
|
||||
|
||||
String apiName = BBPSConstant.API_GET_MASTER_DATA;
|
||||
String requestId = masterRequest.getReqId();
|
||||
String mid = masterRequest.getMid();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={}", apiName, requestId, mid);
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String requestJson = helper.convertObjectToJson(masterRequest);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, masterRequest.getMid(), BBPSConstant.HTTP_POST,
|
||||
requestJson);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, masterRequest.getMid(),
|
||||
BBPSConstant.HTTP_POST, requestJson);
|
||||
helper.validateMerchant(mid);
|
||||
try {
|
||||
// Merchant Validation
|
||||
helper.validateMerchant(masterRequest.getMid());
|
||||
// check Tenant Id is present DB
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
if (headersData == null) {
|
||||
@@ -122,7 +125,8 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
// get full url
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.MASTER_CATEGORY_URL + headersData.getTenantId();
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
@@ -132,7 +136,8 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
helper.updateInboundLogFailure(inboundLog, responseData,
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode
|
||||
@@ -147,51 +152,59 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
|
||||
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
|
||||
return responseModel;
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel getBillerByBillerId(BillerDetailRequest billerDetailRequest) {
|
||||
LOGGER.info("Fetching Biller Detail By Biller Id for ReqId={} and MID={}", billerDetailRequest.getReqId(),
|
||||
billerDetailRequest.getMid());
|
||||
|
||||
helper.validateMerchant(billerDetailRequest.getMid());
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = BBPSConstant.API_GET_BILLER_BY_ID;
|
||||
String requestId = billerDetailRequest.getReqId();
|
||||
String billerId = billerDetailRequest.getBillerId();
|
||||
String mid = billerDetailRequest.getMid();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, requestId, mid, billerId);
|
||||
|
||||
// 2. Transaction Id
|
||||
String txnID = helper.generateTxnId(15);
|
||||
// 3. Prepare URL
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.BILLER_DATA_FETCH_URL + billerId;
|
||||
// 4. Prepare Logs
|
||||
String requestJson = helper.convertObjectToJson(billerDetailRequest);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, billerDetailRequest.getMid(),
|
||||
BBPSConstant.HTTP_POST, requestJson);
|
||||
helper.validateMerchant(mid);
|
||||
|
||||
System.out.println(billerDataRespository.findByBillerId(billerId));
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("fetched data from api is :{}", responseData);
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
try {
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)),
|
||||
helper.updateInboundLogFailure(inboundLog, responseData,
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)),
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)),
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))),
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
|
||||
}
|
||||
// Mapping to Model
|
||||
BillerDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillerDataResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
ModelMapper mapper = new ModelMapper();
|
||||
@@ -203,6 +216,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
|
||||
return responseModel;
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
@@ -210,26 +224,27 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResponseModel getCustomerParamByBillerId(CustomParamRequest customerParamRequest) {
|
||||
|
||||
LOGGER.info("Fetching Customer Param By Biller Id for ReqId={} and MID={}", customerParamRequest.getReqId(),
|
||||
customerParamRequest.getMid());
|
||||
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = BBPSConstant.API_GET_CUSTOMER_PARAM_BY_BILLER_ID;
|
||||
String requestId = customerParamRequest.getReqId();
|
||||
String mid = customerParamRequest.getMid();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, requestId, mid,
|
||||
customerParamRequest.getBillerId());
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String billerId = customerParamRequest.getBillerId();
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.CUSTOMPARAM_URL + billerId;
|
||||
|
||||
String requestJson = helper.convertObjectToJson(customerParamRequest);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, customerParamRequest.getMid(),
|
||||
BBPSConstant.HTTP_POST, requestJson);
|
||||
|
||||
helper.validateMerchant(mid);
|
||||
try {
|
||||
helper.validateMerchant(customerParamRequest.getMid());
|
||||
String billerId = customerParamRequest.getBillerId();
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.CUSTOMPARAM_URL + billerId;
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
@@ -241,10 +256,12 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
helper.updateInboundLogFailure(inboundLog, responseData,
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode (int)
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode
|
||||
// (int)
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
|
||||
}
|
||||
|
||||
@@ -260,11 +277,12 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
.collect(Collectors.toList());
|
||||
// Save all to DB
|
||||
customParamReposiotory.saveAll(entities);
|
||||
LOGGER.info("[{}] Saved {} custom param records to DB", apiName, entities.size());
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
|
||||
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
|
||||
return responseModel;
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
@@ -275,28 +293,32 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
@Override
|
||||
public ResponseModel getContactMaster(ContactMasterRequest contactMasterRequest) {
|
||||
LOGGER.info("Fetching Contact Master Request Data " + contactMasterRequest);
|
||||
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = BBPSConstant.API_FETCH_MASTER_DATA_CATEGORY_WISE;
|
||||
String apiName = BBPSConstant.API_FETCH_CATEGORY_MASTER_DATA;
|
||||
String requestId = contactMasterRequest.getReqId();
|
||||
String mid = contactMasterRequest.getMid();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | category={}", apiName, requestId, contactMasterRequest.getMid(),
|
||||
contactMasterRequest.getCategory());
|
||||
String txnID = helper.generateTxnId(15);
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
String fullUrl = masterRegisterUrl + String.format(BBPSConstant.CONTACT_MASTER_URL, headersData.getTenantId(),
|
||||
contactMasterRequest.getCategory());
|
||||
|
||||
String requestJson = helper.convertObjectToJson(contactMasterRequest);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, contactMasterRequest.getMid(),
|
||||
BBPSConstant.HTTP_POST, requestJson);
|
||||
helper.validateMerchant(mid);
|
||||
try {
|
||||
helper.validateMerchant(contactMasterRequest.getMid());
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
String fullUrl = masterRegisterUrl + String.format(BBPSConstant.CONTACT_MASTER_URL,
|
||||
headersData.getTenantId(), contactMasterRequest.getCategory());
|
||||
|
||||
LOGGER.info("Contact Master Full URL-:" + fullUrl);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Response Data: {}", responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
@@ -304,7 +326,8 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
helper.updateInboundLogFailure(inboundLog, responseData,
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode
|
||||
@@ -316,7 +339,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
String result = mapperHelper.saveContactMasterData(responseWrapper.getContactMasterList(), requestId,
|
||||
txnID);
|
||||
|
||||
LOGGER.info("Result Master Contact Data -:" + result);
|
||||
LOGGER.info("[{}] DB Save Result | reqId={} | result={}", apiName, requestId, result);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
@@ -324,6 +347,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
|
||||
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
|
||||
return responseModel;
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
@@ -334,26 +358,34 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
@Override
|
||||
public ResponseModel fetchMasterDataCategoryWise(MasterCategoryRequest masterRequest) {
|
||||
LOGGER.info("Fetching Master Data CategoryResponseList-wise " + masterRequest);
|
||||
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = BBPSConstant.API_FETCH_MASTER_DATA_CATEGORY_WISE;
|
||||
String requestId = masterRequest.getReqId();
|
||||
String mid = masterRequest.getMid();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billerName={} | category={}", apiName, requestId, mid,
|
||||
masterRequest.getBillerName(), masterRequest.getCategory());
|
||||
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String fullUrl = String.format("%s%s?billerName=%s&category=%s&page=%d&pagesize=%d", masterRegisterUrl,
|
||||
BBPSConstant.BILLER_URL, masterRequest.getBillerName(), masterRequest.getCategory(),
|
||||
masterRequest.getPageNo(), masterRequest.getPageSize());
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
String requestJson = helper.convertObjectToJson(masterRequest);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, masterRequest.getMid(), BBPSConstant.HTTP_POST,
|
||||
requestJson);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, masterRequest.getMid(),
|
||||
BBPSConstant.HTTP_POST, requestJson);
|
||||
helper.validateMerchant(mid);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
|
||||
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, BBPSConstant.HTTP_GET, null);
|
||||
|
||||
LOGGER.info("[{}] Calling External API | URL={} | Method=GET", apiName, fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
// LOGGER.info("Response Data: {}", responseData);
|
||||
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
@@ -362,7 +394,8 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
helper.updateInboundLogFailure(inboundLog, responseData,
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode
|
||||
@@ -373,6 +406,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
BillerResponse responseWrapper = objectMapper.convertValue(dataMap, BillerResponse.class);
|
||||
List<BillerCategoryWise> savedEntities = mapperHelper.mapAndSaveAll(responseWrapper.getBillerResp(),
|
||||
requestId, txnID);
|
||||
LOGGER.info("[{}] Saved {} records to DB | reqId={}", apiName, savedEntities.size(), requestId);
|
||||
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
|
||||
@@ -380,7 +414,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
|
||||
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
|
||||
return responseModel;
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
@@ -391,49 +425,54 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
@Override
|
||||
public ResponseModel getDispositionDetails(DispositionRequest dispositionDetailRequest) {
|
||||
LOGGER.info("Fetching Disposition Details for ReqId={} and MID={}", dispositionDetailRequest.getReqId(),
|
||||
dispositionDetailRequest.getMid());
|
||||
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = BBPSConstant.API_GET_TICKET_DISPOSITIONS;
|
||||
String requestId = dispositionDetailRequest.getReqId();
|
||||
helper.validateMerchant(dispositionDetailRequest.getMid());
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
|
||||
dispositionDetailRequest.getMid(), BBPSConstant.HTTP_GET, "N/A");
|
||||
|
||||
String mid = dispositionDetailRequest.getMid();
|
||||
String requestJson = helper.convertObjectToJson(dispositionDetailRequest);
|
||||
LOGGER.info("[{}] START | reqId={} | mid={}", apiName, requestId, mid);
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.DISPOSTION_URL;
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
|
||||
dispositionDetailRequest.getMid(), BBPSConstant.HTTP_GET, requestJson);
|
||||
helper.validateMerchant(mid);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_GET, requestJson);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
try {
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
helper.updateInboundLogFailure(inboundLog, responseData,
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode (int)
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode
|
||||
// (int)
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
|
||||
}
|
||||
|
||||
DispositionResponse responseWrapper = objectMapper.convertValue(dataMap, DispositionResponse.class);
|
||||
System.out.println(responseWrapper);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
ModelMapper mapper = new ModelMapper();
|
||||
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||
List<DispositionDetails> entities = responseWrapper.getDispositionsList().stream()
|
||||
.map(dto -> mapper.map(dto, DispositionDetails.class)).collect(Collectors.toList());
|
||||
|
||||
System.out.println(entities);
|
||||
|
||||
LOGGER.info("[{}] Dispositions Received: {}", apiName, entities.size());
|
||||
if (entities != null) {
|
||||
dispositionRepository.saveAll(entities);
|
||||
} else {
|
||||
|
||||
LOGGER.warn("No disposition found in response to save.");
|
||||
}
|
||||
|
||||
@@ -442,6 +481,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
|
||||
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
|
||||
return responseModel;
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
@@ -453,20 +493,24 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
@Override
|
||||
public ResponseModel fetchCustomerParamGroup(BillerDetailRequest requestModel) {
|
||||
LOGGER.info("Fetching Customer Param Group for ReqId={} and MID={}", requestModel.getReqId(),
|
||||
requestModel.getMid());
|
||||
String txnID = helper.generateTxnId(15);
|
||||
|
||||
String apiName = BBPSConstant.API_FETCH_CUSTOMER_PARAM_GROUP;
|
||||
String requestId = requestModel.getReqId();
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), BBPSConstant.HTTP_POST,
|
||||
helper.convertObjectToJson(requestModel));
|
||||
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(),
|
||||
BBPSConstant.HTTP_POST, helper.convertObjectToJson(requestModel));
|
||||
|
||||
try {
|
||||
helper.validateMerchant(requestModel.getMid());
|
||||
LOGGER.info("[{}] Calling External API | URL={} | Method=GET", apiName, fullUrl);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.CUSTOMER_PARAM_GROUP + requestModel.getBillerId();
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
|
||||
String responseData = apiResponse.get(BBPSConstant.RESPONSE_DATA_KEY).toString();
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
@@ -476,10 +520,12 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
helper.updateInboundLogFailure(inboundLog, responseData,
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode (int)
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode
|
||||
// (int)
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
|
||||
}
|
||||
|
||||
@@ -490,10 +536,13 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
CustomerParamGroupsDTO responseDTO = mapperHelper
|
||||
.saveCustomerParamGroups(responseWrapper.getCustomerParamGroupResp(), requestId, txnID);
|
||||
|
||||
LOGGER.info("[{}] Saved {} Customer Param Group records | reqId={}", apiName, responseDTO.toString(),
|
||||
requestId);
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
|
||||
|
||||
return responseModel;
|
||||
|
||||
@@ -508,24 +557,29 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
@Override
|
||||
public ResponseModel fetchAllMasterAmountOption(BillerDetailRequest requestModel) {
|
||||
|
||||
LOGGER.info("Fetching Master Data Amount List for ReqId={} and MID={}", requestModel.getReqId(),
|
||||
requestModel.getMid());
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = BBPSConstant.API_FETCH_ALL_MASTER_AMOUNT_OPTION;
|
||||
String requestId = requestModel.getReqId();
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), BBPSConstant.HTTP_POST,
|
||||
helper.convertObjectToJson(requestModel));
|
||||
String mid = requestModel.getMid();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, requestId, mid,
|
||||
requestModel.getBillerId());
|
||||
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.AMOUNT_OPTIONS + requestModel.getBillerId();
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(),
|
||||
BBPSConstant.HTTP_POST, helper.convertObjectToJson(requestModel));
|
||||
helper.validateMerchant(mid);
|
||||
try {
|
||||
helper.validateMerchant(requestModel.getMid());
|
||||
LOGGER.info("[{}] Calling External API | URL={} | Method=GET", apiName, fullUrl);
|
||||
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.AMOUNT_OPTIONS + requestModel.getBillerId();
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
|
||||
LOGGER.info("Response" + apiResponse);
|
||||
String responseData = apiResponse.get(BBPSConstant.RESPONSE_DATA_KEY).toString();
|
||||
|
||||
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
@@ -533,10 +587,12 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
helper.updateInboundLogFailure(inboundLog, responseData,
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode (int)
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode
|
||||
// (int)
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
|
||||
}
|
||||
|
||||
@@ -544,6 +600,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
String saveAmountOptionsResponse = mapperHelper.saveAmountOptionsResponse(responseWrapper, requestId,
|
||||
txnID);
|
||||
LOGGER.info("[{}] Save Result | reqId={} | result={}", apiName, requestId, saveAmountOptionsResponse);
|
||||
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
|
||||
@@ -552,6 +609,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
|
||||
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
|
||||
return responseModel;
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
@@ -564,18 +622,23 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
@Override
|
||||
public ResponseModel fetchPlanCategorie(BillerDetailRequest requestModel) {
|
||||
LOGGER.info("Fetching Plan Categories for ReqId={} and MID={}", requestModel.getReqId(), requestModel.getMid());
|
||||
String txnID = helper.generateTxnId(15);
|
||||
|
||||
String apiName = BBPSConstant.API_FETCH_PLAN_CATEGORIES;
|
||||
String requestId = requestModel.getReqId();
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), BBPSConstant.HTTP_POST,
|
||||
helper.convertObjectToJson(requestModel));
|
||||
|
||||
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(),
|
||||
BBPSConstant.HTTP_POST, helper.convertObjectToJson(requestModel));
|
||||
helper.validateMerchant(mid);
|
||||
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, BBPSConstant.HTTP_GET, null);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
|
||||
LOGGER.info("Response" + apiResponse);
|
||||
@@ -588,23 +651,28 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
helper.updateInboundLogFailure(inboundLog, responseData,
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode (int)
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode
|
||||
// (int)
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
|
||||
}
|
||||
|
||||
PlaneCategoriesResponse responseWrapper = objectMapper.convertValue(dataMap, PlaneCategoriesResponse.class);
|
||||
|
||||
mapperHelper.saveCategoryItems(responseWrapper.getCategoryRespList(), requestId, txnID);
|
||||
String saveCategoryItems = mapperHelper.saveCategoryItems(responseWrapper.getCategoryRespList(), requestId,
|
||||
txnID);
|
||||
LOGGER.info("[{}] Saved category items | reqId={} | count={}", apiName, requestId, saveCategoryItems);
|
||||
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
|
||||
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
|
||||
return responseModel;
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
@@ -617,20 +685,21 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
@Override
|
||||
public ResponseModel fetchInitiatingChannel(BillerDetailRequest requestModel) {
|
||||
LOGGER.info("Fetching Initiating Channel for ReqId={} and MID={}", requestModel.getReqId(),
|
||||
requestModel.getMid());
|
||||
String txnID = helper.generateTxnId(15);
|
||||
|
||||
String apiName = BBPSConstant.API_FETCH_INITIATING_CHANNEL;
|
||||
String requestId = requestModel.getReqId();
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), BBPSConstant.HTTP_POST,
|
||||
helper.convertObjectToJson(requestModel));
|
||||
|
||||
String mid = requestModel.getMid();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={}", apiName, requestId, mid);
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.INITIATING_CHANNEL;
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(),
|
||||
BBPSConstant.HTTP_POST, helper.convertObjectToJson(requestModel));
|
||||
helper.validateMerchant(mid);
|
||||
try {
|
||||
helper.validateMerchant(requestModel.getMid());
|
||||
LOGGER.info("[{}] Calling Master API | URL={} | Method=GET", apiName, fullUrl);
|
||||
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.INITIATING_CHANNEL;
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.info("Calling Master API: {}", fullUrl);
|
||||
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
|
||||
LOGGER.info("Response" + apiResponse);
|
||||
@@ -643,10 +712,12 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
helper.updateInboundLogFailure(inboundLog, responseData,
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode (int)
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode
|
||||
// (int)
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
|
||||
}
|
||||
|
||||
@@ -657,6 +728,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
|
||||
|
||||
return responseModel;
|
||||
|
||||
@@ -670,14 +742,12 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
public ResponseModel fetchPlanByCategories(PlanRequest requestModel) {
|
||||
|
||||
LOGGER.info("Fetching Plan By Categories for ReqId={} and MID={}", requestModel.getReqId(),
|
||||
requestModel.getMid());
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = BBPSConstant.API_FETCH_PLAN_BY_CATEGORIES;
|
||||
String requestId = requestModel.getReqId();
|
||||
|
||||
helper.validateMerchant(requestModel.getMid());
|
||||
|
||||
String mid = requestModel.getMid();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, requestId, mid,
|
||||
requestModel.getBillerId());
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String url = String.format("%s%s?billerId=%s%s%s%s&page=%d&pagesize=%d", masterRegisterUrl,
|
||||
BBPSConstant.PLANS_URL, requestModel.getBillerId(),
|
||||
requestModel.getCategory() != null ? "&category=" + requestModel.getCategory() : "",
|
||||
@@ -689,11 +759,16 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
// Convert request to JSON and create inbound & outbound logs
|
||||
String requestJson = helper.convertObjectToJson(requestModel);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), BBPSConstant.HTTP_POST,
|
||||
requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, BBPSConstant.HTTP_GET, null);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(),
|
||||
BBPSConstant.HTTP_POST, requestJson);
|
||||
helper.validateMerchant(mid);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, BBPSConstant.HTTP_GET,
|
||||
null);
|
||||
try {
|
||||
LOGGER.info("[{}] Calling Master API | URL={} | Method=GET", apiName, url);
|
||||
Map<String, String> apiResponse = httpService.getRequest(url);
|
||||
|
||||
String responseData = apiResponse.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Response Data: {}", responseData);
|
||||
|
||||
@@ -706,7 +781,8 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
// Failure response
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
helper.updateInboundLogFailure(inboundLog, responseData,
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)),
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)),
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))),
|
||||
@@ -717,11 +793,14 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
PlanResponse responseWrapper = objectMapper.convertValue(dataMap, PlanResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
|
||||
mapperHelper.savePlanResponse(responseWrapper, requestId, txnID);
|
||||
PlanResponses savePlanResponse = mapperHelper.savePlanResponse(responseWrapper, requestId, txnID);
|
||||
LOGGER.info("[{}] Saved Plans | reqId={} | count={}", apiName, requestId, savePlanResponse);
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
|
||||
return responseModel;
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
@@ -733,48 +812,54 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
@Override
|
||||
public ResponseModel getTicketDispositions(DispositionRequest dispositionDetailRequest) {
|
||||
LOGGER.info("Fetching Ticket Disposition Details for ReqId={} and MID={}", dispositionDetailRequest.getReqId(),
|
||||
dispositionDetailRequest.getMid());
|
||||
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = BBPSConstant.API_GET_TICKET_DISPOSITIONS;
|
||||
String requestId = dispositionDetailRequest.getReqId();
|
||||
helper.validateMerchant(dispositionDetailRequest.getMid());
|
||||
String mid = dispositionDetailRequest.getMid();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={}", apiName, requestId, mid);
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.TICKET_DISPOSTION_URL;
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
|
||||
dispositionDetailRequest.getMid(), BBPSConstant.HTTP_GET, "N/A");
|
||||
helper.validateMerchant(mid);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.TICKET_DISPOSTION_URL;
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
try {
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
|
||||
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
helper.updateInboundLogFailure(inboundLog, responseData,
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode (int)
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode
|
||||
// (int)
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
|
||||
}
|
||||
|
||||
TicketDispositionResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||
TicketDispositionResponse.class);
|
||||
System.out.println(responseWrapper);
|
||||
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
|
||||
ModelMapper mapper = new ModelMapper();
|
||||
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||
mapperHelper.saveTicketDisoptionDetails(responseWrapper.getDispositionsList(), requestId, txnID);
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
|
||||
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
|
||||
return responseModel;
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// PaymentServiceImpl.java
|
||||
package com.billpaymentservice.bbps.serviceImpl;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -46,7 +45,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
@Service
|
||||
public class PaymentServiceImpl implements PaymentService {
|
||||
|
||||
@Value("${payment.data.url}")
|
||||
private String paymentUrl;
|
||||
|
||||
@@ -107,7 +105,9 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
String requestJson = helper.convertObjectToJson(billPaymentRequest);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, billPaymentRequest.getMid(), BBPSConstant.HTTP_POST, requestJson);
|
||||
LOGGER.debug("Inbound log created for api={} | reqId={} | txnId={}", apiName, requestId, txnId);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, BBPSConstant.HTTP_POST, forwardjson);
|
||||
LOGGER.debug("Outbound log created for api={} | reqId={} | txnId={}", apiName, requestId, txnId);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling BBPS payment URL: {}", url);
|
||||
@@ -116,6 +116,7 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
LOGGER.info("Payment API Response: {}", responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
LOGGER.debug("Outbound log response updated for txnId={}", txnId);
|
||||
|
||||
if (responseData == null || responseData.isEmpty()) {
|
||||
helper.updateInboundLogFailure(inboundLog, BBPSConstant.EMPTY_RESPONSE_FROM_BBPS, BBPSConstant.FAILED_STR);
|
||||
@@ -157,6 +158,7 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
LOGGER.warn("Thread interrupted during payment delay: {}", e.getMessage());
|
||||
}
|
||||
LOGGER.info("Checking transaction status for txnId={}", billPaymentResponse.getTxnId());
|
||||
LOGGER.info("[{}] END | reqId={} | txnId={}", apiName, requestId, txnId);
|
||||
return checkTrasactionStatus(transactionStatusRequest, inboundLog);
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
@@ -171,6 +173,9 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String requestId = transactionStatusRequest.getReqId();
|
||||
|
||||
// START log for internal transaction status check
|
||||
LOGGER.info("[{}] START (internal) | checkTxnId={} | reqId={} | bankTxnId={}", apiName, txnId, requestId, transactionStatusRequest.getTxnId());
|
||||
|
||||
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
|
||||
|
||||
LOGGER.info("Checking transaction status (internal) for txnId={} and reqId={}", transactionStatusRequest.getTxnId(), requestId);
|
||||
@@ -179,12 +184,14 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.debug("Outbound log created for internal status check | txnId={} | reqId={}", txnId, requestId);
|
||||
|
||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Transaction status response: {}", responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
LOGGER.debug("Outbound log response updated for internal status check | txnId={}", txnId);
|
||||
|
||||
try {
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
|
||||
@@ -225,6 +232,7 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
LOGGER.info("[{}] END (internal) | checkTxnId={} | reqId={} | status={}", apiName, txnId, requestId, generalResp.getStatus());
|
||||
return responseModel;
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
@@ -240,6 +248,7 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = BBPSConstant.API_CHECK_TRANSACTION_PUBLIC;
|
||||
String requestId = transactionStatusRequest.getReqId();
|
||||
LOGGER.info("[{}] START (public) | reqId={} | mid={} | checkBankTxnId={}", apiName, requestId, transactionStatusRequest.getMid(), transactionStatusRequest.getTxnId());
|
||||
String requestJson = helper.convertObjectToJson(transactionStatusRequest);
|
||||
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
|
||||
|
||||
@@ -249,12 +258,15 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, transactionStatusRequest.getMid(), BBPSConstant.HTTP_POST, requestJson);
|
||||
LOGGER.debug("Inbound log created for public status check | reqId={} | txnId={}", requestId, txnID);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.debug("Outbound log created for public status check | reqId={} | txnId={}", requestId, txnID);
|
||||
|
||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Transaction status response data: {}", responseData);
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
LOGGER.debug("Outbound log response updated for public status check | reqId={} | txnId={}", requestId, txnID);
|
||||
|
||||
try {
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
|
||||
@@ -283,6 +295,7 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
LOGGER.info("[{}] END (public) | reqId={} | txnId={} | status={}", apiName, requestId, txnID, generalResp.getStatus());
|
||||
return responseModel;
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
@@ -294,7 +307,6 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
|
||||
@Override
|
||||
public ResponseModel checkTrasactionStatusByClientReqId(TrasactionStatusByClientReqIdRequest transactionStatusRequest) {
|
||||
|
||||
helper.validateMerchant(transactionStatusRequest.getMid());
|
||||
|
||||
String txnID = helper.generateTxnId(15);
|
||||
@@ -303,7 +315,7 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
String clientReqId = transactionStatusRequest.getClientReqId();
|
||||
String requestJson = helper.convertObjectToJson(transactionStatusRequest);
|
||||
|
||||
LOGGER.info("Checking transaction status for clientReqId={} and reqId={}", clientReqId, requestId);
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | clientReqId={}", apiName, requestId, transactionStatusRequest.getMid(), clientReqId);
|
||||
|
||||
Optional<PaymentInitiate> paymentInitiate = paymentIntiateRepository.findByReqId(clientReqId);
|
||||
if (paymentInitiate.isEmpty()) {
|
||||
@@ -317,9 +329,11 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(
|
||||
requestId, txnID, apiName, transactionStatusRequest.getMid(), BBPSConstant.HTTP_POST, requestJson);
|
||||
LOGGER.debug("Inbound log created for clientReqId check | reqId={} | txnId={}", requestId, txnID);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(
|
||||
txnID, requestId, apiName, url, BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.debug("Outbound log created for clientReqId check | reqId={} | txnId={}", requestId, txnID);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling BBPS Transaction Status API URL={}", url);
|
||||
@@ -329,6 +343,7 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
LOGGER.info("Transaction Status Response: {}", responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
LOGGER.debug("Outbound log response updated for clientReqId check | reqId={} | txnId={}", requestId, txnID);
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(
|
||||
responseData, new TypeReference<Map<String, Object>>() {});
|
||||
@@ -355,6 +370,7 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
LOGGER.info("Transaction Status for clientReqId={} => {}", clientReqId, generalResp.getStatus());
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
LOGGER.info("[{}] END | reqId={} | clientReqId={} | status={}", apiName, requestId, clientReqId, generalResp.getStatus());
|
||||
return new ResponseModel(
|
||||
generalResp.getMessage(),
|
||||
generalResp.getStatus(),
|
||||
@@ -372,15 +388,17 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
|
||||
@Override
|
||||
public ResponseModel handlePaymentIntiateCallback(TransactionStatusResponse transactionStatusResponse) {
|
||||
|
||||
LOGGER.info("Recived Call Back from FetchBillValidateResponse: {}", transactionStatusResponse);
|
||||
String apiName = "HANDLE_PAYMENT_INITIATE_CALLBACK";
|
||||
LOGGER.info("[{}] START | payload={} ", apiName, transactionStatusResponse);
|
||||
LOGGER.info("Received Call Back: {}", transactionStatusResponse);
|
||||
if (transactionStatusResponse.getGeneralResp().getStatusCode().equals(BBPSConstant.SUCCESS_CODE_STR)) {
|
||||
|
||||
LOGGER.info("Callback indicates SUCCESS with status={}", transactionStatusResponse.getGeneralResp().getStatus());
|
||||
} else {
|
||||
LOGGER.info("Bill Fetch Callback Failed with Status: {}", transactionStatusResponse.getGeneralResp().getStatus());
|
||||
|
||||
LOGGER.info("Callback indicates FAILURE with status={}", transactionStatusResponse.getGeneralResp().getStatus());
|
||||
}
|
||||
|
||||
LOGGER.info("[{}] END | callback processed", apiName);
|
||||
|
||||
return new ResponseModel(BBPSConstant.CALLBACK_RECEIVED_SUCCESS,
|
||||
BBPSConstant.SUCCESS_CODE_STR,
|
||||
BBPSConstant.HTTP_OK_INT,
|
||||
|
||||
@@ -93,6 +93,7 @@ public class BBPSConstant {
|
||||
public static final String API_GET_BILLER_BY_ID = "GetBillerByBillerId";
|
||||
public static final String API_GET_CUSTOMER_PARAM_BY_BILLER_ID = "GetCustomerParamByBillerId";
|
||||
public static final String API_FETCH_MASTER_DATA_CATEGORY_WISE = "FetchMasterDataCategoryWise";
|
||||
public static final String API_FETCH_CATEGORY_MASTER_DATA = "FetchContactMasterResponse";
|
||||
public static final String API_FETCH_CUSTOMER_PARAM_GROUP = "FetchCustomerParamGroup";
|
||||
public static final String API_FETCH_ALL_MASTER_AMOUNT_OPTION = "FetchAllMasterAmountOption";
|
||||
public static final String API_FETCH_PLAN_CATEGORIES = "FetchPlanCategorie";
|
||||
|
||||
@@ -33,8 +33,10 @@ import com.billpaymentservice.bbps.dto.TicketDetailsDTO;
|
||||
import com.billpaymentservice.bbps.dto.TicketDispositionsDTO;
|
||||
import com.billpaymentservice.bbps.dto.request.BillFetchByBillIdRequest;
|
||||
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.FetchBillValidatestRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.GetTicketLatestStausRequest;
|
||||
import com.billpaymentservice.bbps.dto.response.AmountOptionsResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.BillDataResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.ClientReqIdResponse;
|
||||
@@ -48,6 +50,8 @@ import com.billpaymentservice.bbps.dto.response.ViewComplainByIdResponse;
|
||||
import com.billpaymentservice.bbps.dto.sentRequest.BillPaymentForwardRequest;
|
||||
import com.billpaymentservice.bbps.dto.sentRequest.FetchBillForwardRequest;
|
||||
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.AdditionalInfoBillValidate;
|
||||
import com.billpaymentservice.bbps.entites.AdditionalInfoPlans;
|
||||
@@ -137,10 +141,8 @@ public class BillerMapperHelper {
|
||||
CheckClientBillerDataRepository checkClientBillerDataRepository,
|
||||
TicketDispositionRepository ticketDispositionRepository,
|
||||
ViewAllComplainTicketDetailRepository viewAllComplainTicketDetailRepository,
|
||||
ContactMasterDataRepository contactMasterDataRepository,
|
||||
BBPSMasterDataRepo bbpsMasterDataRepo,
|
||||
BillerDataRepository billerDataRespository,
|
||||
BillMasterRepository billMasterRepository,
|
||||
ContactMasterDataRepository contactMasterDataRepository, BBPSMasterDataRepo bbpsMasterDataRepo,
|
||||
BillerDataRepository billerDataRespository, BillMasterRepository billMasterRepository,
|
||||
BillValidationRepository billValidationRepository) {
|
||||
this.billerRepo = billerRepo;
|
||||
this.customerParamGroupByBillerIdRepo = customerParamGroupByBillerIdRepo;
|
||||
@@ -860,196 +862,202 @@ public class BillerMapperHelper {
|
||||
|
||||
public void saveOrUpdateBillerData(BillerDetails newEntity) {
|
||||
|
||||
Optional<BillerDetails> existingOpt = billerDataRespository.findByBillerId(newEntity.getBillerId());
|
||||
Optional<BillerDetails> existingOpt = billerDataRespository.findByBillerId(newEntity.getBillerId());
|
||||
|
||||
if (existingOpt.isPresent()) {
|
||||
//logic to be written
|
||||
}
|
||||
else {
|
||||
// brand new biller
|
||||
billerDataRespository.save(newEntity);
|
||||
}
|
||||
if (existingOpt.isPresent()) {
|
||||
// logic to be written
|
||||
} else {
|
||||
// brand new biller
|
||||
billerDataRespository.save(newEntity);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveOrUpdateBillData(BillDataResponse responseWrapper,
|
||||
BillFetchByBillIdRequest billFetchByBillIdRequest,String txnId) {
|
||||
public void saveOrUpdateBillData(BillDataResponse responseWrapper,
|
||||
BillFetchByBillIdRequest billFetchByBillIdRequest, String txnId) {
|
||||
|
||||
BillMaster billMaster = new BillMaster();
|
||||
|
||||
BillMaster billMaster = new BillMaster();
|
||||
|
||||
billMaster.setBillId(responseWrapper.getBillId());
|
||||
billMaster.setRefId(responseWrapper.getRefId());
|
||||
billMaster.setBillerId(responseWrapper.getBillerId());
|
||||
billMaster.setStatus(responseWrapper.getStatus());
|
||||
billMaster.setActionType(responseWrapper.getActionType());
|
||||
billMaster.setUserId(responseWrapper.getUserId());
|
||||
billMaster.setReqId(billFetchByBillIdRequest.getReqId());
|
||||
billMaster.setTxnId(txnId);
|
||||
billMaster.setBillId(responseWrapper.getBillId());
|
||||
billMaster.setRefId(responseWrapper.getRefId());
|
||||
billMaster.setBillerId(responseWrapper.getBillerId());
|
||||
billMaster.setStatus(responseWrapper.getStatus());
|
||||
billMaster.setActionType(responseWrapper.getActionType());
|
||||
billMaster.setUserId(responseWrapper.getUserId());
|
||||
billMaster.setReqId(billFetchByBillIdRequest.getReqId());
|
||||
billMaster.setTxnId(txnId);
|
||||
|
||||
// BILLER RESPONSE
|
||||
BillerResponse billerResponse = new BillerResponse();
|
||||
if (responseWrapper.getBillerResponse() != null) {
|
||||
billerResponse.setBillId(responseWrapper.getBillerResponse().getBillId());
|
||||
billerResponse.setAmount(responseWrapper.getBillerResponse().getAmount());
|
||||
billerResponse.setBillDate(responseWrapper.getBillerResponse().getBillDate());
|
||||
billerResponse.setBillNumber(responseWrapper.getBillerResponse().getBillNumber());
|
||||
billerResponse.setBillPeriod(responseWrapper.getBillerResponse().getBillPeriod());
|
||||
billerResponse.setCustConvFee(responseWrapper.getBillerResponse().getCustConvFee());
|
||||
billerResponse.setCouCustConvFee(responseWrapper.getBillerResponse().getCouCustConvFee());
|
||||
billerResponse.setDueDate(responseWrapper.getBillerResponse().getDueDate());
|
||||
billerResponse.setCustomerName(responseWrapper.getBillerResponse().getCustomerName());
|
||||
billerResponse.setAmountOption(responseWrapper.getBillerResponse().isAmountOption());
|
||||
billerResponse.setBillMaster(billMaster);
|
||||
}
|
||||
billMaster.setBillerResponse(billerResponse);
|
||||
|
||||
|
||||
BillerResponse billerResponse = new BillerResponse();
|
||||
if (responseWrapper.getBillerResponse() != null) {
|
||||
billerResponse.setBillId(responseWrapper.getBillerResponse().getBillId());
|
||||
billerResponse.setAmount(responseWrapper.getBillerResponse().getAmount());
|
||||
billerResponse.setBillDate(responseWrapper.getBillerResponse().getBillDate());
|
||||
billerResponse.setBillNumber(responseWrapper.getBillerResponse().getBillNumber());
|
||||
billerResponse.setBillPeriod(responseWrapper.getBillerResponse().getBillPeriod());
|
||||
billerResponse.setCustConvFee(responseWrapper.getBillerResponse().getCustConvFee());
|
||||
billerResponse.setCouCustConvFee(responseWrapper.getBillerResponse().getCouCustConvFee());
|
||||
billerResponse.setDueDate(responseWrapper.getBillerResponse().getDueDate());
|
||||
billerResponse.setCustomerName(responseWrapper.getBillerResponse().getCustomerName());
|
||||
billerResponse.setAmountOption(responseWrapper.getBillerResponse().isAmountOption());
|
||||
billerResponse.setBillMaster(billMaster);
|
||||
}
|
||||
billMaster.setBillerResponse(billerResponse);
|
||||
|
||||
// ADDITIONAL INFO
|
||||
List<AdditionalInfoBill> additionalInfos = new ArrayList<>();
|
||||
if (responseWrapper.getAdditionalInfo() != null) {
|
||||
for (AdditionalInfoBillDTO info : responseWrapper.getAdditionalInfo()) {
|
||||
AdditionalInfoBill entity = new AdditionalInfoBill();
|
||||
entity.setName(info.getName());
|
||||
entity.setValue(info.getValue());
|
||||
entity.setBillMaster(billMaster);
|
||||
additionalInfos.add(entity);
|
||||
}
|
||||
}
|
||||
billMaster.setAdditionalInfo(additionalInfos);
|
||||
|
||||
|
||||
List<AdditionalInfoBill> additionalInfos = new ArrayList<>();
|
||||
if (responseWrapper.getAdditionalInfo() != null) {
|
||||
for (AdditionalInfoBillDTO info : responseWrapper.getAdditionalInfo()) {
|
||||
AdditionalInfoBill entity = new AdditionalInfoBill();
|
||||
entity.setName(info.getName());
|
||||
entity.setValue(info.getValue());
|
||||
entity.setBillMaster(billMaster);
|
||||
additionalInfos.add(entity);
|
||||
}
|
||||
}
|
||||
billMaster.setAdditionalInfo(additionalInfos);
|
||||
|
||||
// CUSTOMER PARAMS
|
||||
List<CustomerParamBill> customerParams = new ArrayList<>();
|
||||
if (responseWrapper.getCustomerParams() != null) {
|
||||
for (CustomerParamDAO param : responseWrapper.getCustomerParams()) {
|
||||
CustomerParamBill entity = new CustomerParamBill();
|
||||
entity.setName(param.getName());
|
||||
entity.setValue(param.getValue() == null ? "" : param.getValue());
|
||||
entity.setType(param.getType() == null ? "" : param.getType());
|
||||
entity.setBillMaster(billMaster);
|
||||
customerParams.add(entity);
|
||||
}
|
||||
}
|
||||
billMaster.setCustomerParams(customerParams);
|
||||
|
||||
|
||||
List<CustomerParamBill> customerParams = new ArrayList<>();
|
||||
if (responseWrapper.getCustomerParams() != null) {
|
||||
for (CustomerParamDAO param : responseWrapper.getCustomerParams()) {
|
||||
CustomerParamBill entity = new CustomerParamBill();
|
||||
entity.setName(param.getName());
|
||||
entity.setValue(param.getValue() == null ? "" : param.getValue());
|
||||
entity.setType(param.getType() == null ? "" : param.getType());
|
||||
entity.setBillMaster(billMaster);
|
||||
customerParams.add(entity);
|
||||
}
|
||||
}
|
||||
billMaster.setCustomerParams(customerParams);
|
||||
|
||||
// DATES
|
||||
billMaster.setCreationDate(responseWrapper.getCreationDate());
|
||||
billMaster.setModifiedDate(responseWrapper.getModifiedDate());
|
||||
billMaster.setCreatedEpochDate(responseWrapper.getCreatedEpochDate());
|
||||
billMaster.setModifiedEpochDate(responseWrapper.getModifiedEpochDate());
|
||||
billMaster.setCreationDate(responseWrapper.getCreationDate());
|
||||
billMaster.setModifiedDate(responseWrapper.getModifiedDate());
|
||||
billMaster.setCreatedEpochDate(responseWrapper.getCreatedEpochDate());
|
||||
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();
|
||||
|
||||
try {
|
||||
LOGGER.info("Saving bill validation data for billId={}", responseWrapper.getBillId());
|
||||
|
||||
// ✅ Map the main object
|
||||
BillValidation billEntity = modelMapper.map(responseWrapper, BillValidation.class);
|
||||
// ✅ Manually handle only the nested relationship part
|
||||
if (responseWrapper.getCustomerParams() != null) {
|
||||
List<CustomerParamBillValidation> customerParams = responseWrapper.getCustomerParams()
|
||||
.stream()
|
||||
.map(param -> {
|
||||
CustomerParamBillValidation cp = modelMapper.map(param, CustomerParamBillValidation.class);
|
||||
cp.setBill(billEntity); // maintain relation
|
||||
return cp;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
billEntity.setCustomerParams(customerParams);
|
||||
}
|
||||
if (responseWrapper.getAdditionalInfo() != null) {
|
||||
List<AdditionalInfoBillValidate> additionalInfos = responseWrapper.getAdditionalInfo()
|
||||
.stream()
|
||||
.map(info -> {
|
||||
AdditionalInfoBillValidate ai = modelMapper.map(info, AdditionalInfoBillValidate.class);
|
||||
ai.setBill(billEntity); // maintain relation
|
||||
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) {
|
||||
LOGGER.error("Error saving BillValidation data: {}", ex.getMessage(), ex);
|
||||
throw new RuntimeException("Failed to save bill validation data", ex);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public FetchBillForwardRequest fetchBillForwardRequestMap(FetchBillRequest req) {
|
||||
|
||||
FetchBillForwardRequest forward = new FetchBillForwardRequest();
|
||||
|
||||
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 FetchBillValidatestForwardRequest fetchBillValidatestForwardRequest(FetchBillValidatestRequest req) {
|
||||
|
||||
FetchBillValidatestForwardRequest forward = new FetchBillValidatestForwardRequest();
|
||||
|
||||
forward.setBillerId(req.getBillerId());
|
||||
forward.setBillerName(req.getBillerName());
|
||||
forward.setBillerCategory(req.getBillerCategory());
|
||||
forward.setCustomerMobNo(req.getCustomerMobNo());
|
||||
forward.setClientReqId(req.getClientReqId());
|
||||
forward.setMacAddress(req.getMacAddress());
|
||||
forward.setCustomerParamsRequest(req.getCustomerParamsRequest());
|
||||
|
||||
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 void saveBillValidation(FetchBillValidateResponse responseWrapper, BillFetchByBillIdRequest billRequest) {
|
||||
System.out.println("responseWrapper");
|
||||
ModelMapper modelMapper = new ModelMapper();
|
||||
|
||||
try {
|
||||
LOGGER.info("Saving bill validation data for billId={}", responseWrapper.getBillId());
|
||||
|
||||
// ✅ Map the main object
|
||||
BillValidation billEntity = modelMapper.map(responseWrapper, BillValidation.class);
|
||||
// ✅ Manually handle only the nested relationship part
|
||||
if (responseWrapper.getCustomerParams() != null) {
|
||||
List<CustomerParamBillValidation> customerParams = responseWrapper.getCustomerParams().stream()
|
||||
.map(param -> {
|
||||
CustomerParamBillValidation cp = modelMapper.map(param, CustomerParamBillValidation.class);
|
||||
cp.setBill(billEntity); // maintain relation
|
||||
return cp;
|
||||
}).collect(Collectors.toList());
|
||||
billEntity.setCustomerParams(customerParams);
|
||||
}
|
||||
if (responseWrapper.getAdditionalInfo() != null) {
|
||||
List<AdditionalInfoBillValidate> additionalInfos = responseWrapper.getAdditionalInfo().stream()
|
||||
.map(info -> {
|
||||
AdditionalInfoBillValidate ai = modelMapper.map(info, AdditionalInfoBillValidate.class);
|
||||
ai.setBill(billEntity); // maintain relation
|
||||
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) {
|
||||
LOGGER.error("Error saving BillValidation data: {}", ex.getMessage(), ex);
|
||||
throw new RuntimeException("Failed to save bill validation data", ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public FetchBillForwardRequest fetchBillForwardRequestMap(FetchBillRequest req) {
|
||||
|
||||
FetchBillForwardRequest forward = new FetchBillForwardRequest();
|
||||
|
||||
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 FetchBillValidatestForwardRequest fetchBillValidatestForwardRequest(FetchBillValidatestRequest req) {
|
||||
|
||||
FetchBillValidatestForwardRequest forward = new FetchBillValidatestForwardRequest();
|
||||
|
||||
forward.setBillerId(req.getBillerId());
|
||||
forward.setBillerName(req.getBillerName());
|
||||
forward.setBillerCategory(req.getBillerCategory());
|
||||
forward.setCustomerMobNo(req.getCustomerMobNo());
|
||||
forward.setClientReqId(req.getClientReqId());
|
||||
forward.setMacAddress(req.getMacAddress());
|
||||
forward.setCustomerParamsRequest(req.getCustomerParamsRequest());
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.billpaymentservice.bbps.entites.BBPSMastersData;
|
||||
import com.billpaymentservice.bbps.entites.InboundTraceLog;
|
||||
import com.billpaymentservice.bbps.entites.OutboundTraceLog;
|
||||
@@ -32,14 +33,15 @@ public class Helper {
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
private final BBPSMasterDataRepo bbpsMasterDataRepo;
|
||||
|
||||
|
||||
// Constructor Injection
|
||||
public Helper(BBPSMasterDataRepo bbpsMasterDataRepo, InboundTraceLogRepository inboundTraceLogRepository,
|
||||
OutboundTraceLogRepository outboundTraceLogRepository,BillerDataRepository billerDataRepository,
|
||||
BillMasterRepository billMasterRepository,BillValidationRepository billValidationRepository) {
|
||||
|
||||
OutboundTraceLogRepository outboundTraceLogRepository, BillerDataRepository billerDataRepository,
|
||||
BillMasterRepository billMasterRepository, BillValidationRepository billValidationRepository) {
|
||||
this.inboundTraceLogRepository = inboundTraceLogRepository;
|
||||
this.outboundTraceLogRepository = outboundTraceLogRepository;
|
||||
this.bbpsMasterDataRepo = bbpsMasterDataRepo;}
|
||||
this.bbpsMasterDataRepo = bbpsMasterDataRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates whether the merchant exists and is active.
|
||||
@@ -100,14 +102,14 @@ public class Helper {
|
||||
return "{}"; // or "N/A" depending on your needs
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ---------- Trace helper methods ---------- */
|
||||
|
||||
|
||||
public InboundTraceLog createInboundLog(String requestId, String txnId, String apiName, String mid,
|
||||
String httpMethod, String requestPayload) {
|
||||
if(inboundTraceLogRepository.findByRequestId(requestId) != null) {
|
||||
throw new CustomException("Duplicate Request ID: " + requestId);
|
||||
}
|
||||
if (inboundTraceLogRepository.findByRequestId(requestId) != null) {
|
||||
throw new CustomException("Duplicate Request ID: " + requestId);
|
||||
}
|
||||
InboundTraceLog inboundLog = new InboundTraceLog(requestId, txnId, apiName, mid == null ? "N/A" : mid,
|
||||
"BBPS_ORG", httpMethod, requestPayload == null ? "N/A" : requestPayload);
|
||||
inboundTraceLogRepository.save(inboundLog);
|
||||
@@ -124,7 +126,7 @@ public class Helper {
|
||||
inboundTraceLogRepository.save(inboundLog);
|
||||
}
|
||||
|
||||
public void updateInboundLogFailure(InboundTraceLog inboundLog, String responsePayload, String responseCode) {
|
||||
public void updateInboundLogFailure(InboundTraceLog inboundLog, String responsePayload, String responseCode) {
|
||||
if (inboundLog == null)
|
||||
return;
|
||||
inboundLog.setResponsePayload(responsePayload);
|
||||
@@ -149,18 +151,19 @@ public class Helper {
|
||||
outboundLog.setResponseReceiveTime(LocalDateTime.now());
|
||||
outboundTraceLogRepository.save(outboundLog);
|
||||
}
|
||||
|
||||
/* ---------- End helpers ---------- */
|
||||
|
||||
// New reusable header builder for BBPS calls
|
||||
public HttpHeaders buildHeaders(BharatConnectMaster headersData) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
if (headersData != null) {
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
}
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
return headers;
|
||||
}
|
||||
public HttpHeaders buildHeaders(BharatConnectMaster headersData) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
if (headersData != null) {
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
}
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
return headers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,9 +20,9 @@ swagger.server.description=Local Development Server
|
||||
# DataSource
|
||||
spring.datasource.url=jdbc:postgresql://localhost:5432/BBPS
|
||||
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.type=com.zaxxer.hikari.HikariDataSource
|
||||
|
||||
|
||||
Reference in New Issue
Block a user