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