merged with himanshu code after bbps contant added
This commit is contained in:
@@ -9,12 +9,15 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||
import com.billpaymentservice.bbps.dto.request.BillFetchByBillIdRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.BillFetchByClientIdRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.BillValidateByClientIdRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.FetchBillRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.FetchBillValidatestRequest;
|
||||
import com.billpaymentservice.bbps.dto.response.BillDataResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.FetchBillValidateResponse;
|
||||
import com.billpaymentservice.bbps.service.AgentService;
|
||||
|
||||
@RestController
|
||||
@@ -86,5 +89,18 @@ public class AgentController {
|
||||
ResponseModel response = agentService.fetchBillValidateByClientReqId(billValidateByClientIdRequest);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value="/callback/billFetch", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> handleBillFetchCallback(@RequestBody BillDataResponse billDataResponse) {
|
||||
ResponseModel genralResp=agentService.processBillFetchCallback(billDataResponse);
|
||||
// Return a response indicating successful receipt
|
||||
return ResponseEntity.ok(genralResp);
|
||||
}
|
||||
|
||||
@PostMapping(value="/callback/billValidate", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> handleBillValidateCallback(@RequestBody FetchBillValidateResponse fetchBillValidateResponse) {
|
||||
ResponseModel genralResp=agentService.processBillValidateCallback(fetchBillValidateResponse);
|
||||
// Return a response indicating successful receipt
|
||||
return ResponseEntity.ok(genralResp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.TransactionStatusRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.TrasactionStatusByClientReqIdRequest;
|
||||
import com.billpaymentservice.bbps.dto.response.FetchBillValidateResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.TransactionStatusResponse;
|
||||
import com.billpaymentservice.bbps.service.PaymentService;
|
||||
|
||||
@RestController
|
||||
@@ -51,5 +53,12 @@ public class PaymentController {
|
||||
ResponseModel response = paymentService.checkTrasactionStatusByClientReqId(transactionStatusRequest);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
@PostMapping(value="/callback/paymentIntiate", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> handleBillValidateCallback(@RequestBody TransactionStatusResponse transactionStatusResponse) {
|
||||
ResponseModel genralResp=paymentService.handlePaymentIntiateCallback(transactionStatusResponse);
|
||||
// Return a response indicating successful receipt
|
||||
return ResponseEntity.ok(genralResp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.billpaymentservice.bbps.dto.request.BillFetchByClientIdRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.BillValidateByClientIdRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.FetchBillRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.FetchBillValidatestRequest;
|
||||
import com.billpaymentservice.bbps.dto.response.BillDataResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.FetchBillValidateResponse;
|
||||
|
||||
public interface AgentService {
|
||||
|
||||
@@ -21,4 +23,8 @@ public interface AgentService {
|
||||
|
||||
ResponseModel fetchBillValidateByClientReqId( BillValidateByClientIdRequest billValidateByClientIdRequest);
|
||||
|
||||
ResponseModel processBillFetchCallback(BillDataResponse billDataResponse);
|
||||
|
||||
ResponseModel processBillValidateCallback(FetchBillValidateResponse billValidateResponse);
|
||||
|
||||
}
|
||||
|
||||
@@ -4,13 +4,17 @@ import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.TransactionStatusRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.TrasactionStatusByClientReqIdRequest;
|
||||
import com.billpaymentservice.bbps.dto.response.TransactionStatusResponse;
|
||||
|
||||
public interface PaymentService {
|
||||
|
||||
public ResponseModel initiatePayment(BillPaymentRequest billPaymentRequest);
|
||||
ResponseModel initiatePayment(BillPaymentRequest billPaymentRequest);
|
||||
|
||||
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest);
|
||||
ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest);
|
||||
|
||||
ResponseModel checkTrasactionStatusByClientReqId(TrasactionStatusByClientReqIdRequest transactionStatusRequest);
|
||||
ResponseModel checkTrasactionStatusByClientReqId(TrasactionStatusByClientReqIdRequest transactionStatusRequest);
|
||||
|
||||
ResponseModel handlePaymentIntiateCallback(TransactionStatusResponse transactionStatusResponse);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
|
||||
package com.billpaymentservice.bbps.serviceImpl;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestClient;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||
import com.billpaymentservice.bbps.dto.request.BillFetchByBillIdRequest;
|
||||
@@ -23,7 +21,6 @@ import com.billpaymentservice.bbps.dto.response.FetchBillResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.FetchBillValidateResponse;
|
||||
import com.billpaymentservice.bbps.dto.sentRequest.FetchBillForwardRequest;
|
||||
import com.billpaymentservice.bbps.dto.sentRequest.FetchBillValidatestForwardRequest;
|
||||
import com.billpaymentservice.bbps.entites.BharatConnectMaster;
|
||||
import com.billpaymentservice.bbps.entites.BillInitiate;
|
||||
import com.billpaymentservice.bbps.entites.BillMaster;
|
||||
import com.billpaymentservice.bbps.entites.InboundTraceLog;
|
||||
@@ -42,7 +39,6 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Service
|
||||
public class AgentServiceImpl implements AgentService {
|
||||
@@ -59,6 +55,10 @@ public class AgentServiceImpl implements AgentService {
|
||||
private final BillInitateRepository billIntiateRepository;
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AgentServiceImpl.class);
|
||||
|
||||
// Reusable ObjectMapper instance
|
||||
private final ObjectMapper objectMapper = new ObjectMapper()
|
||||
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
|
||||
public AgentServiceImpl(RestClient restClient, HttpService httpService, Helper helper,
|
||||
BharatConnectMasterRepository beneficiaryDetailsRepository,
|
||||
InboundTraceLogRepository inboundTraceLogRepository, OutboundTraceLogRepository outboundTraceLogRepository,
|
||||
@@ -76,7 +76,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
@Override
|
||||
public ResponseModel initiateBillFetch(FetchBillRequest fetchBillRequest) {
|
||||
|
||||
String apiName = "InitiateBillFetch";
|
||||
String apiName = BBPSConstant.API_INITIATE_BILL_FETCH;
|
||||
String requestId = fetchBillRequest.getReqId();
|
||||
String mid = fetchBillRequest.getMid();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, requestId, mid,
|
||||
@@ -85,31 +85,23 @@ public class AgentServiceImpl implements AgentService {
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_INTI;
|
||||
fetchBillRequest.setClientReqId(txnId);
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
FetchBillForwardRequest forwardReq = helper.fetchBillForwardRequestMap(fetchBillRequest);
|
||||
FetchBillForwardRequest forwardReq = mapperHelper.fetchBillForwardRequestMap(fetchBillRequest);
|
||||
|
||||
String forwardJson = helper.convertObjectToJson(forwardReq);
|
||||
String requestJson = helper.convertObjectToJson(fetchBillRequest);
|
||||
|
||||
// ✅ Create inbound & outbound logs
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, fetchBillRequest.getMid(),
|
||||
"POST", requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, fullUrl, "POST",
|
||||
forwardJson);
|
||||
BBPSConstant.HTTP_POST, requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_POST, forwardJson);
|
||||
LOGGER.debug("Outbound log created successfully for txnId: {} and reqId: {}", txnId, requestId);
|
||||
|
||||
try {
|
||||
|
||||
LOGGER.info("[{}] Calling external API | URL={}", apiName, fullUrl);
|
||||
Map<String, String> responseMap = httpService.postRequest(fullUrl, forwardJson, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
Map<String, String> responseMap = httpService.postRequest(fullUrl, forwardJson,
|
||||
helper.buildHeaders(beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID)));
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
LOGGER.debug("Response received from BBPS: {}", responseData);
|
||||
@@ -117,8 +109,8 @@ public class AgentServiceImpl implements AgentService {
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERIC_KEY)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
LOGGER.warn("Invalid response received for txnId: {}", txnId);
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
@@ -149,7 +141,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
billFetchByBillIdRequest.setReqId(requestId);
|
||||
LOGGER.info("Waiting for 2 seconds before fetching bill by ID...");
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
Thread.sleep((long) BBPSConstant.BILL_FETCH_DELAY_MS);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
LOGGER.warn("Thread interrupted during delay: {}", e.getMessage());
|
||||
@@ -159,7 +151,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
return fetchBillById(billFetchByBillIdRequest, inboundLog);
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("JSON Parsing Error: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
@@ -167,27 +159,22 @@ public class AgentServiceImpl implements AgentService {
|
||||
public ResponseModel fetchBillById(BillFetchByBillIdRequest billFetchByBillIdRequest, InboundTraceLog inboundLog) {
|
||||
LOGGER.info("Fetching bill by BILLID for request ID={} and MID={}", billFetchByBillIdRequest.getReqId(),
|
||||
billFetchByBillIdRequest.getMid());
|
||||
String apiName = "FetchBillById";
|
||||
String apiName = BBPSConstant.API_FETCH_BILL_BY_ID;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = billFetchByBillIdRequest.getReqId();
|
||||
String billId = billFetchByBillIdRequest.getBillId();
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + billFetchByBillIdRequest.getBillId();
|
||||
helper.validateMerchant(billFetchByBillIdRequest.getMid());
|
||||
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, fullUrl, "GET", null);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET,
|
||||
null);
|
||||
LOGGER.debug("Outbound log created successfully for FetchBillById: {}", fullUrl);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl,
|
||||
helper.buildHeaders(beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID)));
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Bill FetchById Response: {}", responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
@@ -196,8 +183,8 @@ public class AgentServiceImpl implements AgentService {
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERIC_KEY)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
LOGGER.warn("Invalid response structure for txnId: {}", txnId);
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
@@ -211,71 +198,56 @@ public class AgentServiceImpl implements AgentService {
|
||||
LOGGER.info("Current Bill Status: {}", status);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
helper.saveOrUpdateBillData(responseWrapper, billFetchByBillIdRequest, txnId);
|
||||
mapperHelper.saveOrUpdateBillData(responseWrapper, billFetchByBillIdRequest, txnId);
|
||||
LOGGER.info("Bill data saved successfully for billId: {}", billId);
|
||||
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing BillById JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel fetchBillById(BillFetchByBillIdRequest billFetchByBillIdRequest) {
|
||||
String apiName = "FetchBillById";
|
||||
|
||||
String apiName = BBPSConstant.API_FETCH_BILL_BY_ID;
|
||||
String reqId = billFetchByBillIdRequest.getReqId();
|
||||
String billId = billFetchByBillIdRequest.getBillId();
|
||||
String mid = billFetchByBillIdRequest.getMid();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billId={}", apiName, reqId, mid, billId);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + billFetchByBillIdRequest.getBillId();
|
||||
|
||||
helper.validateMerchant(mid);
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + billFetchByBillIdRequest.getBillId();
|
||||
|
||||
LOGGER.info("Initiating {} API for billId={} and reqId={}", apiName, billId, reqId);
|
||||
|
||||
// create inbound log (GET -> no request body)
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, billFetchByBillIdRequest.getMid(),
|
||||
"GET", null);
|
||||
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.info("Initiating {} API for billId={} and reqId={}", apiName, billId, reqId);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET,
|
||||
null);
|
||||
try {
|
||||
LOGGER.debug("Merchant validated successfully for MID={}", 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);
|
||||
LOGGER.info("Calling external BBPS API for FetchBillById, URL={}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl,
|
||||
helper.buildHeaders(beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID)));
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Response received from BBPS for billId={} : {}", billId, responseData);
|
||||
|
||||
// create outbound log
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||
LOGGER.info("[{}] Calling BBPS FetchBillById API | URL={}", apiName, fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.debug("[{}] BBPS Response | billId={} | data={}", apiName, billId, responseData);
|
||||
|
||||
// update outbound log with response
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
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")), // message
|
||||
String.valueOf(dataMap.get("status")), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode
|
||||
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(),
|
||||
@@ -288,17 +260,18 @@ public class AgentServiceImpl implements AgentService {
|
||||
LOGGER.info("[{}] END | reqId={} | status={}", apiName, reqId, generalResp.getStatus());
|
||||
return responseModel;
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
}
|
||||
|
||||
catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON for billId={} : {}", billId, e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel initiateBillValidate(FetchBillValidatestRequest fetchBillValidateRequest) {
|
||||
|
||||
String apiName = "InitiateBillValidate";
|
||||
String apiName = BBPSConstant.API_INITIATE_BILL_VALIDATE;
|
||||
String reqId = fetchBillValidateRequest.getReqId();
|
||||
String mid = fetchBillValidateRequest.getMid();
|
||||
|
||||
@@ -309,32 +282,25 @@ public class AgentServiceImpl implements AgentService {
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILLER_VALIDATE_URL;
|
||||
fetchBillValidateRequest.setClientReqId(txnId);
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
FetchBillValidatestForwardRequest forwardReq = helper
|
||||
FetchBillValidatestForwardRequest forwardReq = mapperHelper
|
||||
.fetchBillValidatestForwardRequest(fetchBillValidateRequest);
|
||||
|
||||
String forwardJson = helper.convertObjectToJson(forwardReq);
|
||||
|
||||
String requestJson = helper.convertObjectToJson(fetchBillValidateRequest);
|
||||
|
||||
// ✅ Create inbound & outbound logs
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, fetchBillValidateRequest.getMid(),
|
||||
"POST", requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "POST", forwardJson);
|
||||
BBPSConstant.HTTP_POST, requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_POST,
|
||||
forwardJson);
|
||||
LOGGER.debug("Outbound log created successfully for txnId: {} and reqId: {}", txnId, reqId);
|
||||
|
||||
try {
|
||||
|
||||
LOGGER.info("[{}] Calling external API | URL={}", apiName, fullUrl);
|
||||
Map<String, String> responseMap = httpService.postRequest(fullUrl, forwardJson, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
Map<String, String> responseMap = httpService.postRequest(fullUrl, forwardJson,
|
||||
helper.buildHeaders(beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID)));
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
LOGGER.debug("Response received from BBPS: {}", responseData);
|
||||
@@ -342,8 +308,8 @@ public class AgentServiceImpl implements AgentService {
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERIC_KEY)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
LOGGER.warn("Invalid response received for txnId: {}", txnId);
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
@@ -373,8 +339,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
billFetchByBillIdRequest.setReqId(reqId);
|
||||
LOGGER.info("Waiting for 2 seconds before fetching bill by ID...");
|
||||
try {
|
||||
|
||||
Thread.sleep(12000);
|
||||
Thread.sleep((long) BBPSConstant.BILL_VALIDATE_DELAY_MS);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
LOGGER.warn("Thread interrupted during delay: {}", e.getMessage());
|
||||
@@ -384,40 +349,32 @@ public class AgentServiceImpl implements AgentService {
|
||||
return BillvaidateByBillId(billFetchByBillIdRequest, inboundLog);
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("JSON Parsing Error: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ResponseModel BillvaidateByBillId(BillFetchByBillIdRequest billRequest, InboundTraceLog inboundLog) {
|
||||
{
|
||||
LOGGER.info("Validating bill by BILLID for request ID={} and MID={}", billRequest.getReqId(),
|
||||
billRequest.getMid());
|
||||
String apiName = "FetchBillById";
|
||||
String apiName = BBPSConstant.API_FETCH_BILL_BY_ID;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = billRequest.getReqId();
|
||||
String billId = billRequest.getBillId();
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_VALIDATE_ID_URL + billRequest.getBillId();
|
||||
;
|
||||
|
||||
helper.validateMerchant(billRequest.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, fullUrl, "GET", null);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.debug("Outbound log created successfully for FetchBillById: {}", fullUrl);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl,
|
||||
helper.buildHeaders(beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID)));
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Bill FetchById Response: {}", responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
@@ -426,8 +383,8 @@ public class AgentServiceImpl implements AgentService {
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERIC_KEY)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
LOGGER.warn("Invalid response structure for txnId: {}", txnId);
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")),
|
||||
String.valueOf(dataMap.get("status")),
|
||||
@@ -444,14 +401,14 @@ public class AgentServiceImpl implements AgentService {
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
System.out.println("responseWrapper:" + responseWrapper);
|
||||
helper.saveBillValidation(responseWrapper, billRequest);
|
||||
mapperHelper.saveBillValidation(responseWrapper, billRequest);
|
||||
LOGGER.info("Bill data saved successfully for billId: {}", billId);
|
||||
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing BillById JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
|
||||
@@ -460,7 +417,9 @@ public class AgentServiceImpl implements AgentService {
|
||||
|
||||
@Override
|
||||
public ResponseModel initiateBillValidateByBillId(BillFetchByBillIdRequest billRequest) {
|
||||
String apiName = "FetchBillById";
|
||||
|
||||
String apiName = BBPSConstant.API_FETCH_BILL_BY_ID;
|
||||
|
||||
String reqId = billRequest.getReqId();
|
||||
String billId = billRequest.getBillId();
|
||||
String mid = billRequest.getMid();
|
||||
@@ -472,36 +431,28 @@ public class AgentServiceImpl implements AgentService {
|
||||
|
||||
LOGGER.info("Initiating {} API for billId={} and reqId={}", apiName, billId, reqId);
|
||||
|
||||
// create inbound log (GET -> no request body)
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, billRequest.getMid(), "GET", null);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, billRequest.getMid(),
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
|
||||
try {
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
// create outbound log
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.info("Calling external BBPS API for ValidateByBillId, URL={}", fullUrl);
|
||||
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
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);
|
||||
|
||||
// update outbound log with response
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new com.fasterxml.jackson.core.type.TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
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"))),
|
||||
@@ -512,9 +463,8 @@ public class AgentServiceImpl implements AgentService {
|
||||
FetchBillValidateResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||
|
||||
// update inbound log and save validation data
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
helper.saveBillValidation(responseWrapper, billRequest);
|
||||
mapperHelper.saveBillValidation(responseWrapper, billRequest);
|
||||
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(),
|
||||
@@ -522,18 +472,23 @@ public class AgentServiceImpl implements AgentService {
|
||||
|
||||
} catch (com.fasterxml.jackson.core.JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing ValidateByBillId JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
// ================================== Bill fetch and Bill Validate by Client Req
|
||||
// Id==================================//
|
||||
// =======
|
||||
|
||||
// ... remaining methods unchanged except where headers/objectMapper were
|
||||
// previously created (they now use buildHeaders() and the class-level
|
||||
// objectMapper)
|
||||
// >>>>>>>d0812656ff2aee80b1eb0c0ab8e29a01d7d66553
|
||||
|
||||
@Override
|
||||
public ResponseModel fetchBillValidateByClientReqId(BillValidateByClientIdRequest billValidateByClientIdRequest) {
|
||||
|
||||
String apiName = "FetchBillValidateByClientIdRequest";
|
||||
String apiName = BBPSConstant.API_FETCH_BILL_VALIDATE_BY_CLIENT_ID;
|
||||
String reqId = billValidateByClientIdRequest.getReqId();
|
||||
String clientReqId = billValidateByClientIdRequest.getClientReqId();
|
||||
String mid = billValidateByClientIdRequest.getMid();
|
||||
@@ -545,30 +500,22 @@ public class AgentServiceImpl implements AgentService {
|
||||
String txnId = helper.generateTxnId(15);
|
||||
Optional<BillInitiate> billInitiate = billIntiateRepository.findByReqId(clientReqId);
|
||||
if (billInitiate.isEmpty()) {
|
||||
throw new CustomException("No Bill Found for given Client Req Id");
|
||||
throw new CustomException(BBPSConstant.NO_BILL_FOUND);
|
||||
}
|
||||
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_VALIDATE_BY_CLIENT_REQ_ID + billInitiate.get().getTxnId();
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
// 🔵 Create Inbound + Outbound Logs
|
||||
helper.validateMerchant(billValidateByClientIdRequest.getMid());
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName,
|
||||
billValidateByClientIdRequest.getMid(), "GET", null);
|
||||
billValidateByClientIdRequest.getMid(), BBPSConstant.HTTP_GET, null);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET,
|
||||
null);
|
||||
|
||||
try {
|
||||
LOGGER.info("[{}] Calling BBPS API | URL={} | reqId={}", apiName, fullUrl, reqId);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("Calling BBPS API FetchBillValidateByClientReqId, URL={}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl,
|
||||
helper.buildHeaders(beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID)));
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
@@ -576,8 +523,8 @@ public class AgentServiceImpl implements AgentService {
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERIC_KEY)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
String.valueOf(dataMap.get("remarks")));
|
||||
@@ -593,7 +540,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
@@ -601,7 +548,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
@Override
|
||||
public ResponseModel fetchBillByClientReqId(BillFetchByClientIdRequest billFetchByClientIdRequest) {
|
||||
|
||||
String apiName = "FetchBillByClientIdRequest";
|
||||
String apiName = BBPSConstant.API_FETCH_BILL_BY_CLIENT_ID;
|
||||
String reqId = billFetchByClientIdRequest.getReqId();
|
||||
String clientReqId = billFetchByClientIdRequest.getClientReqId();
|
||||
String mid = billFetchByClientIdRequest.getMid();
|
||||
@@ -613,30 +560,22 @@ public class AgentServiceImpl implements AgentService {
|
||||
|
||||
Optional<BillInitiate> billInitiate = billIntiateRepository.findByReqId(clientReqId);
|
||||
if (billInitiate.isEmpty()) {
|
||||
throw new CustomException("No Bill Found for given Client Req Id");
|
||||
throw new CustomException(BBPSConstant.NO_BILL_FOUND);
|
||||
}
|
||||
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_VALIDATE_BY_CLIENT_REQ_ID + billInitiate.get().getTxnId();
|
||||
|
||||
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();
|
||||
|
||||
// 🔵 Create inbound + outbound logs
|
||||
helper.validateMerchant(billFetchByClientIdRequest.getMid());
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, billFetchByClientIdRequest.getMid(),
|
||||
"GET", null);
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET,
|
||||
null);
|
||||
|
||||
try {
|
||||
LOGGER.info("[{}] Calling external API | URL={} | reqId={}", apiName, fullUrl, reqId);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl,
|
||||
helper.buildHeaders(beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID)));
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
@@ -644,8 +583,8 @@ public class AgentServiceImpl implements AgentService {
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERIC_KEY)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
String.valueOf(dataMap.get("remarks")));
|
||||
@@ -660,7 +599,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
@@ -852,4 +791,27 @@ public class AgentServiceImpl implements AgentService {
|
||||
* }
|
||||
*/
|
||||
|
||||
@Override
|
||||
public ResponseModel processBillFetchCallback(BillDataResponse billDataResponse) {
|
||||
LOGGER.info("Recived Call Back from billDataResponse: {}", billDataResponse);
|
||||
if (billDataResponse.getGenericResponse().getStatusCode().equals(BBPSConstant.SUCCESS_CODE_STR)) {
|
||||
} else {
|
||||
LOGGER.info("Bill Fetch Callback Failed with Status: {}",
|
||||
billDataResponse.getGenericResponse().getStatus());
|
||||
}
|
||||
return new ResponseModel(BBPSConstant.CALLBACK_RECEIVED_SUCCESS, BBPSConstant.SUCCESS_CODE_STR,
|
||||
BBPSConstant.HTTP_OK_INT, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel processBillValidateCallback(FetchBillValidateResponse billValidateResponse) {
|
||||
LOGGER.info("Recived Call Back from FetchBillValidateResponse: {}", billValidateResponse);
|
||||
if (billValidateResponse.getGenericResponse().getStatusCode().equals(BBPSConstant.SUCCESS_CODE_STR)) {
|
||||
} else {
|
||||
LOGGER.info("Bill Fetch Callback Failed with Status: {}",
|
||||
billValidateResponse.getGenericResponse().getStatus());
|
||||
}
|
||||
return new ResponseModel(BBPSConstant.CALLBACK_RECEIVED_SUCCESS, BBPSConstant.SUCCESS_CODE_STR,
|
||||
BBPSConstant.HTTP_OK_INT, "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// language: java
|
||||
package com.billpaymentservice.bbps.serviceImpl;
|
||||
|
||||
import java.util.List;
|
||||
@@ -7,7 +8,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestClient;
|
||||
|
||||
@@ -62,8 +62,9 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
private final ComplainRepository complainRepository;
|
||||
private final ComplaintOptionsStatusMasterRepository complaintStatusMasterRepository;
|
||||
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AgentServiceImpl.class);
|
||||
// moved to class-level
|
||||
private final ObjectMapper objectMapper;
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ComplainServiceImpl.class);
|
||||
|
||||
public ComplainServiceImpl(RestClient restClient, HttpService httpService, Helper helper,
|
||||
BharatConnectMasterRepository beneficiaryDetailsRepository, BillerMapperHelper mapperHelper,
|
||||
@@ -76,12 +77,16 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
this.mapperHelper = mapperHelper;
|
||||
this.complainRepository = complainRepository;
|
||||
this.complaintStatusMasterRepository = complaintStatusMasterRepository;
|
||||
|
||||
// initialize shared ObjectMapper once
|
||||
this.objectMapper = new ObjectMapper();
|
||||
this.objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel addComplain(ComplaintRequestDTO complainRequestDTO) {
|
||||
|
||||
String apiName = "ADD_COMPLAIN";
|
||||
String apiName = BBPSConstant.API_ADD_COMPLAIN;
|
||||
String requestId = complainRequestDTO.getReqId();
|
||||
String mid = complainRequestDTO.getMid();
|
||||
|
||||
@@ -92,25 +97,19 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
String fullUrl = complainDataUrl + BBPSConstant.ADD_COMPLAIN_ENDPOINT;
|
||||
LOGGER.info("[{}] Full URL={}", apiName, fullUrl);
|
||||
// Fetch tenant & agent from DB
|
||||
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);
|
||||
// Convert input DTO to JSON
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
FetchComplaintForwardRequest forwardReq = helper.fetchComplaintForwardRequestMap(complainRequestDTO);
|
||||
|
||||
String forwardJson = helper.convertObjectToJson(forwardReq);
|
||||
String requestJson = helper.convertObjectToJson(complainRequestDTO);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, complainRequestDTO.getMid(),
|
||||
"POST", requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, fullUrl, "POST",
|
||||
forwardJson);
|
||||
BBPSConstant.HTTP_POST, requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_POST, null);
|
||||
|
||||
try {
|
||||
// Inject tenantId + agentId into request JSON
|
||||
@@ -124,13 +123,13 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
// IMPORTANT: Send finalJson, not requestJson
|
||||
Map<String, String> responseMap = httpService.postRequest(fullUrl, finalJson, headers);
|
||||
|
||||
String responseData = responseMap.get("data");
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.debug("[{}] Response Received | reqId={} | data={}", apiName, requestId, responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
// Handle HttpService error wrapper
|
||||
if (responseData.startsWith("HttpService Error")) {
|
||||
if (responseData.startsWith(BBPSConstant.HTTP_SERVICE_ERROR_PREFIX)) {
|
||||
int start = responseData.indexOf("{");
|
||||
int end = responseData.lastIndexOf("}");
|
||||
if (start != -1 && end != -1) {
|
||||
@@ -144,13 +143,14 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
int statusCode = Integer.parseInt(String.valueOf(dataMap.get("statusCode")));
|
||||
int statusCode = Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY)));
|
||||
|
||||
// Throw exception for non-200
|
||||
if (statusCode != 200) {
|
||||
if (statusCode != BBPSConstant.HTTP_OK_INT) {
|
||||
LOGGER.warn("[{}] Failure Response | reqId={} | statusCode={}", apiName, requestId, statusCode);
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
statusCode, String.valueOf(dataMap.get("remarks")));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)),
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), statusCode,
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
|
||||
}
|
||||
|
||||
// Convert to response wrapper
|
||||
@@ -165,7 +165,7 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("JSON Parsing Error: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
@@ -173,9 +173,7 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
@Override
|
||||
public ResponseModel getComplaintStatus(GetTicketLatestStausRequest request) {
|
||||
|
||||
LOGGER.info("Fetching Complaint Status for TicketId={} ReqId={}", request.getTicketId(), request.getReqId());
|
||||
|
||||
String apiName = "COMPLAINT_STATUS";
|
||||
String apiName = BBPSConstant.API_COMPLAINT_STATUS;
|
||||
String reqId = request.getReqId();
|
||||
String complaintId = request.getTicketId();
|
||||
String mid = request.getMid();
|
||||
@@ -184,16 +182,11 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | ticketId={}", apiName, reqId, mid, ticketId);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.COMPALINT_STATUS;
|
||||
|
||||
LOGGER.info("FUll URL -: " + fullUrl);
|
||||
helper.validateMerchant(mid);
|
||||
helper.validateMerchant(request.getMid());
|
||||
String txnId = helper.generateTxnId(15);
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
|
||||
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);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
|
||||
// Convert request to JSON
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
@@ -203,10 +196,10 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
String forwardJson = helper.convertObjectToJson(forwardReq);
|
||||
String requestJson = helper.convertObjectToJson(request);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), "POST",
|
||||
requestJson);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "POST", forwardJson);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(),
|
||||
BBPSConstant.HTTP_POST, requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_POST,
|
||||
complaintId);
|
||||
|
||||
try {
|
||||
|
||||
@@ -219,59 +212,56 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
|
||||
Map<String, String> responseMap = httpService.postRequest(fullUrl, finalJson, headers);
|
||||
|
||||
String responseData = responseMap.get("data");
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
|
||||
LOGGER.debug("[{}] Raw Response | reqId={} | data={}", apiName, reqId, responseData);
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
if (responseData.startsWith("HttpService Error")) {
|
||||
// Handle HttpService error wrapper
|
||||
if (responseData.startsWith(BBPSConstant.HTTP_SERVICE_ERROR_PREFIX)) {
|
||||
int start = responseData.indexOf("{");
|
||||
int end = responseData.lastIndexOf("}");
|
||||
if (start != -1 && end != -1) {
|
||||
responseData = responseData.substring(start, end + 1);
|
||||
LOGGER.info("Extracted Clean JSON: {}", responseData);
|
||||
}
|
||||
|
||||
LOGGER.info("Extracted pure JSON from error: {}", responseData);
|
||||
}
|
||||
|
||||
// Convert JSON to Map
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
int statusCode = Integer.parseInt(String.valueOf(dataMap.get("statusCode")));
|
||||
|
||||
if (statusCode != 200) {
|
||||
LOGGER.warn("[{}] Failure Response | reqId={} | statusCode={}", apiName, reqId, statusCode);
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
statusCode, String.valueOf(dataMap.get("remarks")));
|
||||
int statusCode = Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY)));
|
||||
if (statusCode != BBPSConstant.HTTP_OK_INT) {
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)),
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), statusCode,
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
|
||||
}
|
||||
|
||||
TicketCheckStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||
TicketCheckStatusResponse.class);
|
||||
LOGGER.info("[{}] Complaint Status | ticketId={} | status={}", apiName, ticketId,
|
||||
responseWrapper.getStatus());
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, responseWrapper.getStatus());
|
||||
|
||||
// Save in DB
|
||||
String saveComplaintStatus = mapperHelper.saveComplaintStatus(responseWrapper, reqId, txnId);
|
||||
LOGGER.info("[{}] Save Status | ticketId={} | status={}", apiName, ticketId, saveComplaintStatus);
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, responseWrapper.getStatus());
|
||||
|
||||
return new ResponseModel(responseWrapper.getMessage(), responseWrapper.getStatus(),
|
||||
Integer.parseInt(responseWrapper.getStatusCode()), responseWrapper);
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
|
||||
LOGGER.error("Error parsing Complaint Status JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
LOGGER.error("Error parsing JSON in complaint status API: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel viewComplaintHistory(ComplainStatusRequest request) {
|
||||
|
||||
String apiName = "View_Complaint_History";
|
||||
LOGGER.info("Fetching View Complaint History Complaint by Complaint Id={}", request.getTicketId(),
|
||||
request.getReqId());
|
||||
String apiName = BBPSConstant.API_VIEW_COMPLAINT_HISTORY;
|
||||
String reqId = request.getReqId();
|
||||
String ticketId = request.getTicketId();
|
||||
String mid = request.getMid();
|
||||
@@ -281,26 +271,23 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
|
||||
helper.validateMerchant(request.getMid());
|
||||
String txnId = helper.generateTxnId(15);
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
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);
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
|
||||
String requestJson = helper.convertObjectToJson(request);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), "GET",
|
||||
requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", ticketId);
|
||||
LOGGER.debug("[{}] Outbound log created | URL={}", apiName, fullUrl);
|
||||
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);
|
||||
|
||||
try {
|
||||
LOGGER.info("[{}] Calling external API | URL={} | reqId={}", apiName, fullUrl, reqId);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.debug("[{}] Raw Response | reqId={} | data={}", apiName, reqId, responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
@@ -309,11 +296,15 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
LOGGER.warn("[{}] Invalid response structure | reqId={} | data={}", apiName, reqId, responseData);
|
||||
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(""));
|
||||
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
LOGGER.warn("Invalid response structure for txnId: {}", txnId);
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)),
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)),
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))),
|
||||
String.valueOf(""));
|
||||
}
|
||||
|
||||
ComplaintHistoryStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||
@@ -331,14 +322,15 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing Complaint Id JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel viewComplaintById(ComplainStatusRequest request) {
|
||||
String apiName = "View_Complaint_By_ID";
|
||||
|
||||
String apiName = BBPSConstant.API_VIEW_COMPLAINT_BY_ID;
|
||||
String reqId = request.getReqId();
|
||||
String ticketId = request.getTicketId();
|
||||
String mid = request.getMid();
|
||||
@@ -349,26 +341,21 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.VIEW_COMPLAINT_BY_ID + request.getTicketId();
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
String requestJson = helper.convertObjectToJson(request);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), "GET",
|
||||
requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", 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);
|
||||
|
||||
try {
|
||||
LOGGER.info("[{}] Calling external API | reqId={} | URL={}", apiName, reqId, fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Complaint History Complaint FetchById Response: {}", responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
@@ -377,11 +364,13 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
LOGGER.warn("Invalid response structure for txnId: {}", txnId);
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), String.valueOf(""));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)),
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)),
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))),
|
||||
String.valueOf(""));
|
||||
}
|
||||
|
||||
ViewComplainByIdResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||
@@ -399,7 +388,7 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing Complaint Id JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
@@ -408,19 +397,20 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
public ResponseModel getAllActiveStatuses(AllMasterOptionsRequest request) {
|
||||
|
||||
try {
|
||||
String apiName = "View All Options Fetch By Id";
|
||||
String reqId = request.getReqId();
|
||||
String fullUrl = "Data Base Options";
|
||||
String mid = request.getMid();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={}", apiName, reqId, mid);
|
||||
// Validate merchant
|
||||
helper.validateMerchant(mid);
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String requestJson = helper.convertObjectToJson(request);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), "GET",
|
||||
requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||
LOGGER.info("Fetch All Master Options - MID: {}", request.getMid());
|
||||
String apiName = BBPSConstant.API_GET_ALL_MASTER_OPTIONS;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = request.getReqId();
|
||||
String fullUrl = BBPSConstant.DB_OPTIONS;
|
||||
|
||||
String requestJson = helper.convertObjectToJson(request);
|
||||
// Validate merchant
|
||||
helper.validateMerchant(request.getMid());
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(),
|
||||
BBPSConstant.HTTP_GET, requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
|
||||
|
||||
// Fetch data from DB
|
||||
@@ -431,26 +421,31 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
|
||||
// Check empty or null
|
||||
if (allActiveStatuses == null || allActiveStatuses.isEmpty()) {
|
||||
helper.updateInboundLogFailure(inboundLog, allActiveStatuses.toString(), "Null Data From DB");
|
||||
return new ResponseModel("No Master Fields Found", "failed", 404, null, 0);
|
||||
helper.updateInboundLogFailure(inboundLog, String.valueOf(allActiveStatuses),
|
||||
BBPSConstant.NULL_DATA_FROM_DB);
|
||||
return new ResponseModel(BBPSConstant.NO_MASTER_FIELDS_FOUND, BBPSConstant.FAILED_STATUS,
|
||||
BBPSConstant.HTTP_NOT_FOUND, null, 0);
|
||||
}
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, allActiveStatuses.toString(), "200");
|
||||
helper.updateInboundLogSuccess(inboundLog, String.valueOf(allActiveStatuses),
|
||||
String.valueOf(BBPSConstant.HTTP_OK_INT));
|
||||
// SUCCESS RESPONSE
|
||||
return new ResponseModel("All Master Fields Fetch", "SUCCESS", 200, allActiveStatuses,
|
||||
allActiveStatuses.size());
|
||||
return new ResponseModel(BBPSConstant.ALL_MASTER_FIELDS_FETCH, BBPSConstant.SUCCESS_RESPONSE,
|
||||
BBPSConstant.HTTP_OK_INT, allActiveStatuses, allActiveStatuses.size());
|
||||
|
||||
}
|
||||
|
||||
catch (Exception e) {
|
||||
LOGGER.error("Error while fetching master options", e);
|
||||
return new ResponseModel("Something went wrong", "failed", 500, null, 0);
|
||||
return new ResponseModel(BBPSConstant.SOMETHING_WENT_WRONG, BBPSConstant.FAILED_STATUS,
|
||||
BBPSConstant.HTTP_INTERNAL_SERVER_ERROR, null, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ResponseModel checkTxnStatus(TxnStatusRequest request) {
|
||||
String apiName = "Check_Txn_Status";
|
||||
|
||||
String apiName = BBPSConstant.API_CHECK_TXN_STATUS;
|
||||
String reqId = request.getReqId();
|
||||
String ID = request.getId();
|
||||
String mid = request.getMid();
|
||||
@@ -461,26 +456,21 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.CHECK_TRANSACTION_URL + request.getId();
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
String requestJson = helper.convertObjectToJson(request);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), "GET",
|
||||
requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", 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);
|
||||
|
||||
try {
|
||||
LOGGER.info("[{}] Calling external BBPS API | URL={}", apiName, fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("checkTxnStatus: {}", responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
@@ -489,11 +479,13 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
LOGGER.warn("Invalid response structure for txnId: {}", txnId);
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), String.valueOf(""));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)),
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)),
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))),
|
||||
String.valueOf(""));
|
||||
}
|
||||
|
||||
TxnStatusResponse responseWrapper = objectMapper.convertValue(dataMap, TxnStatusResponse.class);
|
||||
@@ -508,7 +500,7 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing Complaint Id JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
|
||||
@@ -517,9 +509,7 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
@Override
|
||||
public ResponseModel ViewAllComplaints(ViewAllComplaintsTicketsRequest request) {
|
||||
|
||||
LOGGER.info("Fetching All Complaint for status Type={} and reqId={} ", request.getStatusType(),
|
||||
request.getReqId());
|
||||
String apiName = "View_All_Complaint_By_Status_Type";
|
||||
String apiName = BBPSConstant.API_VIEW_ALL_COMPLAINTS_BY_STATUS;
|
||||
String reqId = request.getReqId();
|
||||
String mid = request.getMid();
|
||||
String statusType = request.getStatusType();
|
||||
@@ -532,28 +522,22 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
+ "&pageSize=" + request.getPageSize() + "&statusType=" + request.getStatusType() + "&ticketType="
|
||||
+ request.getTicketType();
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
String requestJson = helper.convertObjectToJson(request);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), "GET",
|
||||
requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET",
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(),
|
||||
BBPSConstant.HTTP_POST, requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET,
|
||||
request.getStatusType());
|
||||
LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
|
||||
|
||||
try {
|
||||
LOGGER.info("[{}] Calling external API | URL={}", apiName, fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("[{}] API Response received", apiName);
|
||||
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Response: {}", responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
@@ -561,11 +545,13 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
LOGGER.warn("Invalid response structure for txnId: {}", txnId);
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), String.valueOf(""));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)),
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)),
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))),
|
||||
String.valueOf(""));
|
||||
}
|
||||
|
||||
ViewAllComplaintsTicketsResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||
@@ -582,9 +568,9 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing Complaint Id JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+226
-187
@@ -1,4 +1,3 @@
|
||||
// java
|
||||
package com.billpaymentservice.bbps.serviceImpl;
|
||||
|
||||
import java.util.List;
|
||||
@@ -10,9 +9,8 @@ import org.modelmapper.convention.MatchingStrategies;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.ContactMaster;
|
||||
import com.billpaymentservice.bbps.dto.CustomParamDTO;
|
||||
import com.billpaymentservice.bbps.dto.CustomerParamGroupsDTO;
|
||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||
@@ -57,6 +55,7 @@ import com.billpaymentservice.bbps.util.BBPSConstant;
|
||||
import com.billpaymentservice.bbps.util.BillerMapperHelper;
|
||||
import com.billpaymentservice.bbps.util.EntityRelationshipUtil;
|
||||
import com.billpaymentservice.bbps.util.Helper;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@@ -77,7 +76,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
private final Helper helper;
|
||||
private final BillerDataRepository billerDataRespository;
|
||||
private final HttpService httpService;
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
private final ObjectMapper objectMapper;
|
||||
private final InboundTraceLogRepository inboundTraceLogRepository;
|
||||
private final OutboundTraceLogRepository outboundTraceLogRepository;
|
||||
private final CustomParamRepository customParamReposiotory;
|
||||
@@ -99,50 +98,52 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
this.mapperHelper = mapperHelper;
|
||||
this.customParamReposiotory = customParamReposiotory;
|
||||
|
||||
this.objectMapper = new ObjectMapper();
|
||||
this.objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel getMasterData(MasterRequest masterRequest) {
|
||||
|
||||
String apiName = "GetMasterData";
|
||||
String apiName = BBPSConstant.API_GET_MASTER_DATA;
|
||||
String requestId = masterRequest.getReqId();
|
||||
String mid = masterRequest.getMid();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={}", apiName, requestId, mid);
|
||||
|
||||
// Merchant Validation
|
||||
helper.validateMerchant(mid);
|
||||
|
||||
// check Tender Id is present DB
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
if (headersData == null) {
|
||||
LOGGER.warn("header data not found for the orgID");
|
||||
throw new CustomException("Something went wrong", "FAILED", 500, "");
|
||||
}
|
||||
// get full url
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.MASTER_CATEGORY_URL + headersData.getTenantId();
|
||||
String txnID = helper.generateTxnId(15);
|
||||
|
||||
String requestJson = helper.convertObjectToJson(masterRequest);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, masterRequest.getMid(), "GET",
|
||||
requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", requestJson);
|
||||
try {
|
||||
LOGGER.info("[{}] Calling External API | URL={} | Method=GET", apiName, fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||
String responseData = responseMap.get("data");
|
||||
|
||||
LOGGER.debug("[{}] API Response | reqId={}", apiName, requestId);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, masterRequest.getMid(),
|
||||
BBPSConstant.HTTP_POST, requestJson);
|
||||
try {
|
||||
// check Tenant Id is present DB
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
if (headersData == null) {
|
||||
LOGGER.warn("header data not found for the orgID");
|
||||
throw new CustomException("Something went wrong", "FAILED", 500, "");
|
||||
}
|
||||
// get full url
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.MASTER_CATEGORY_URL + headersData.getTenantId();
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), // message
|
||||
String.valueOf(dataMap.get("status")), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode
|
||||
String.valueOf(dataMap.get("remarks")) // remarks
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData,
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)) // remarks
|
||||
);
|
||||
}
|
||||
|
||||
@@ -158,8 +159,9 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -167,38 +169,46 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
@Override
|
||||
public ResponseModel getBillerByBillerId(BillerDetailRequest billerDetailRequest) {
|
||||
|
||||
String apiName = "Get_Biller_By_BillerId";
|
||||
helper.validateMerchant(billerDetailRequest.getMid());
|
||||
|
||||
String apiName = BBPSConstant.API_GET_BILLER_BY_ID;
|
||||
String requestId = billerDetailRequest.getReqId();
|
||||
String billerId = billerDetailRequest.getBillerId();
|
||||
String mid = billerDetailRequest.getMid();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, requestId, mid, billerId);
|
||||
// 1. Validation
|
||||
helper.validateMerchant(billerDetailRequest.getMid());
|
||||
|
||||
// 2. Transaction Id
|
||||
String txnID = helper.generateTxnId(15);
|
||||
// 3. Prepare URL
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.BILLER_DATA_FETCH_URL + billerId;
|
||||
// 4. Prepare Logs
|
||||
String requestJson = helper.convertObjectToJson(billerDetailRequest);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, fullUrl, "GET", requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", requestJson);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, billerDetailRequest.getMid(),
|
||||
BBPSConstant.HTTP_POST, requestJson);
|
||||
|
||||
System.out.println(billerDataRespository.findByBillerId(billerId));
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("fetched data from api is :{}", responseData);
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
try {
|
||||
LOGGER.info("[{}] Calling external API | URL={}", apiName, fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
// Convert response
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
String.valueOf(dataMap.get("remarks")));
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData,
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)),
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)),
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))),
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
|
||||
}
|
||||
// Mapping to Model
|
||||
BillerDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillerDataResponse.class);
|
||||
@@ -207,7 +217,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||
BillerDetails entity = mapper.map(responseWrapper.getBillerDAO(), BillerDetails.class);
|
||||
EntityRelationshipUtil.linkBillerRelationships(entity);// linking nesting entity foreign key
|
||||
helper.saveOrUpdateBillerData(entity);
|
||||
mapperHelper.saveOrUpdateBillerData(entity);
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
@@ -216,15 +226,14 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
return responseModel;
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel getCustomerParamByBillerId(CustomParamRequest customerParamRequest) {
|
||||
|
||||
String apiName = "GetCustomerParamByBillerId";
|
||||
String apiName = BBPSConstant.API_GET_CUSTOMER_PARAM_BY_BILLER_ID;
|
||||
String requestId = customerParamRequest.getReqId();
|
||||
String mid = customerParamRequest.getMid();
|
||||
|
||||
@@ -237,24 +246,30 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
String requestJson = helper.convertObjectToJson(customerParamRequest);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, customerParamRequest.getMid(),
|
||||
"GET", requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", requestJson);
|
||||
BBPSConstant.HTTP_POST, requestJson);
|
||||
|
||||
try {
|
||||
LOGGER.info("[{}] Calling External API | URL={} | Method=GET", apiName, fullUrl);
|
||||
|
||||
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("data");
|
||||
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("data is :{}", responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), // message
|
||||
String.valueOf(dataMap.get("status")), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode (int)
|
||||
String.valueOf(dataMap.get("remarks")));
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData,
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode
|
||||
// (int)
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
|
||||
}
|
||||
|
||||
CustomParamResp responseWrapper = objectMapper.convertValue(dataMap, CustomParamResp.class);
|
||||
@@ -278,7 +293,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
return responseModel;
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
@@ -286,7 +301,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
@Override
|
||||
public ResponseModel getContactMaster(ContactMasterRequest contactMasterRequest) {
|
||||
|
||||
String apiName = "Fetch_Master_Data_Category_Wise";
|
||||
String apiName = BBPSConstant.API_FETCH_MASTER_DATA_CATEGORY_WISE;
|
||||
String requestId = contactMasterRequest.getReqId();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | category={}", apiName, requestId, contactMasterRequest.getMid(),
|
||||
contactMasterRequest.getCategory());
|
||||
@@ -294,32 +309,36 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
helper.validateMerchant(contactMasterRequest.getMid());
|
||||
String txnID = helper.generateTxnId(15);
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
String fullUrl = masterRegisterUrl + String.format(BBPSConstant.CONTACT_MASTER_URL, headersData.getTenantId(),
|
||||
contactMasterRequest.getCategory());
|
||||
|
||||
String requestJson = helper.convertObjectToJson(contactMasterRequest);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, contactMasterRequest.getMid(),
|
||||
"GET", requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", requestJson);
|
||||
|
||||
BBPSConstant.HTTP_POST, requestJson);
|
||||
try {
|
||||
LOGGER.info("[{}] Calling External API | URL={} | Method=GET", apiName, fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.debug("[{}] External API Response | reqId={} | data={}", apiName, requestId, responseData);
|
||||
|
||||
LOGGER.info("Contact Master Full URL-:" + fullUrl);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Response Data: {}", responseData);
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), // message
|
||||
String.valueOf(dataMap.get("status")), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode
|
||||
String.valueOf(dataMap.get("remarks")) // remarks
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData,
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)) // remarks
|
||||
);
|
||||
}
|
||||
|
||||
@@ -339,7 +358,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
return responseModel;
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
@@ -347,7 +366,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
@Override
|
||||
public ResponseModel fetchMasterDataCategoryWise(MasterCategoryRequest masterRequest) {
|
||||
|
||||
String apiName = "FetchMasterDataCategoryWise";
|
||||
String apiName = BBPSConstant.API_FETCH_MASTER_DATA_CATEGORY_WISE;
|
||||
String requestId = masterRequest.getReqId();
|
||||
String mid = masterRequest.getMid();
|
||||
|
||||
@@ -362,16 +381,18 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
String requestJson = helper.convertObjectToJson(masterRequest);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, masterRequest.getMid(), "POST",
|
||||
requestJson);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, masterRequest.getMid(),
|
||||
BBPSConstant.HTTP_POST, requestJson);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
|
||||
try {
|
||||
|
||||
LOGGER.info("[{}] Calling External API | URL={} | Method=GET", apiName, fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||
String responseData = responseMap.get("data");
|
||||
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
@@ -380,12 +401,13 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), // message
|
||||
String.valueOf(dataMap.get("status")), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode
|
||||
String.valueOf(dataMap.get("remarks")) // remarks
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData,
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)) // remarks
|
||||
);
|
||||
}
|
||||
|
||||
@@ -404,7 +426,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
return responseModel;
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
@@ -412,7 +434,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
@Override
|
||||
public ResponseModel getDispositionDetails(DispositionRequest dispositionDetailRequest) {
|
||||
|
||||
String apiName = "GetDispositionDetails";
|
||||
String apiName = BBPSConstant.API_GET_TICKET_DISPOSITIONS;
|
||||
String requestId = dispositionDetailRequest.getReqId();
|
||||
String mid = dispositionDetailRequest.getMid();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={}", apiName, requestId, mid);
|
||||
@@ -422,27 +444,30 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.DISPOSTION_URL;
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
|
||||
dispositionDetailRequest.getMid(), "GET", "N/A");
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET",
|
||||
dispositionDetailRequest.getMid());
|
||||
dispositionDetailRequest.getMid(), BBPSConstant.HTTP_GET, "N/A");
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
|
||||
|
||||
try {
|
||||
LOGGER.info("[{}] Calling external API | URL={} | Method=GET", apiName, fullUrl);
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||
String responseData = responseMap.get("data");
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), // message
|
||||
String.valueOf(dataMap.get("status")), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode (int)
|
||||
String.valueOf(dataMap.get("remarks")));
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData,
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode
|
||||
// (int)
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
|
||||
}
|
||||
|
||||
DispositionResponse responseWrapper = objectMapper.convertValue(dataMap, DispositionResponse.class);
|
||||
@@ -468,7 +493,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
return responseModel;
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
|
||||
@@ -477,38 +502,39 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
@Override
|
||||
public ResponseModel fetchCustomerParamGroup(BillerDetailRequest requestModel) {
|
||||
|
||||
String apiName = "FetchCustomerParamGroup";
|
||||
String apiName = BBPSConstant.API_FETCH_CUSTOMER_PARAM_GROUP;
|
||||
String requestId = requestModel.getReqId();
|
||||
String mid = requestModel.getMid();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, requestId, mid,
|
||||
requestModel.getBillerId());
|
||||
|
||||
helper.validateMerchant(mid);
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.CUSTOMER_PARAM_GROUP + requestModel.getBillerId();
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "GET",
|
||||
helper.convertObjectToJson(requestModel));
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(),
|
||||
BBPSConstant.HTTP_POST, helper.convertObjectToJson(requestModel));
|
||||
|
||||
try {
|
||||
LOGGER.info("[{}] Calling External API | URL={} | Method=GET", apiName, fullUrl);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
|
||||
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
|
||||
String responseData = apiResponse.get("data").toString();
|
||||
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
|
||||
String responseData = apiResponse.get(BBPSConstant.RESPONSE_DATA_KEY).toString();
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), // message
|
||||
String.valueOf(dataMap.get("status")), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode (int)
|
||||
String.valueOf(dataMap.get("remarks")));
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData,
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode
|
||||
// (int)
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
|
||||
}
|
||||
|
||||
CustomerParamGroupsResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||
@@ -530,7 +556,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
|
||||
@@ -539,7 +565,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
@Override
|
||||
public ResponseModel fetchAllMasterAmountOption(BillerDetailRequest requestModel) {
|
||||
|
||||
String apiName = "FetchAllMasterAmountOption";
|
||||
String apiName = BBPSConstant.API_FETCH_ALL_MASTER_AMOUNT_OPTION;
|
||||
String requestId = requestModel.getReqId();
|
||||
String mid = requestModel.getMid();
|
||||
|
||||
@@ -549,17 +575,19 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
helper.validateMerchant(mid);
|
||||
|
||||
String txnID = helper.generateTxnId(15);
|
||||
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.AMOUNT_OPTIONS + requestModel.getBillerId();
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "POST",
|
||||
helper.convertObjectToJson(requestModel));
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
||||
try {
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(),
|
||||
BBPSConstant.HTTP_POST, helper.convertObjectToJson(requestModel));
|
||||
|
||||
try {
|
||||
LOGGER.info("[{}] Calling External API | URL={} | Method=GET", apiName, fullUrl);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
|
||||
LOGGER.info("Response" + apiResponse);
|
||||
String responseData = apiResponse.get("data").toString();
|
||||
String responseData = apiResponse.get(BBPSConstant.RESPONSE_DATA_KEY).toString();
|
||||
|
||||
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
@@ -568,12 +596,14 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), // message
|
||||
String.valueOf(dataMap.get("status")), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode (int)
|
||||
String.valueOf(dataMap.get("remarks")));
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData,
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode
|
||||
// (int)
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
|
||||
}
|
||||
|
||||
AmountOptionsResponse responseWrapper = objectMapper.convertValue(dataMap, AmountOptionsResponse.class);
|
||||
@@ -594,7 +624,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
|
||||
@@ -603,7 +633,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
@Override
|
||||
public ResponseModel fetchPlanCategorie(BillerDetailRequest requestModel) {
|
||||
|
||||
String apiName = "FetchPlanCategorie";
|
||||
String apiName = BBPSConstant.API_FETCH_PLAN_CATEGORIES;
|
||||
String requestId = requestModel.getReqId();
|
||||
String mid = requestModel.getMid();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, requestId, mid,
|
||||
@@ -612,14 +642,18 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
helper.validateMerchant(requestModel.getMid());
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.PLAN_CATEGORIES + requestModel.getBillerId();
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "GET",
|
||||
helper.convertObjectToJson(requestModel));
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(),
|
||||
BBPSConstant.HTTP_POST, helper.convertObjectToJson(requestModel));
|
||||
|
||||
try {
|
||||
LOGGER.info("[{}] Calling External API | URL={} | Method=GET", apiName, fullUrl);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
|
||||
LOGGER.info("Response" + apiResponse);
|
||||
String responseData = apiResponse.get("data").toString();
|
||||
String responseData = apiResponse.get(BBPSConstant.RESPONSE_DATA_KEY).toString();
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
@@ -627,12 +661,14 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), // message
|
||||
String.valueOf(dataMap.get("status")), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode (int)
|
||||
String.valueOf(dataMap.get("remarks")));
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData,
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode
|
||||
// (int)
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
|
||||
}
|
||||
|
||||
PlaneCategoriesResponse responseWrapper = objectMapper.convertValue(dataMap, PlaneCategoriesResponse.class);
|
||||
@@ -652,7 +688,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
|
||||
@@ -661,7 +697,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
@Override
|
||||
public ResponseModel fetchInitiatingChannel(BillerDetailRequest requestModel) {
|
||||
|
||||
String apiName = "FetchInitiatingChannel";
|
||||
String apiName = BBPSConstant.API_FETCH_INITIATING_CHANNEL;
|
||||
String requestId = requestModel.getReqId();
|
||||
String mid = requestModel.getMid();
|
||||
|
||||
@@ -670,17 +706,17 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
helper.validateMerchant(mid);
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.INITIATING_CHANNEL;
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "GET",
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), BBPSConstant.HTTP_POST,
|
||||
helper.convertObjectToJson(requestModel));
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", mid);
|
||||
|
||||
try {
|
||||
LOGGER.info("[{}] Calling Master API | URL={} | Method=GET", apiName, fullUrl);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.info("Calling Master API: {}", fullUrl);
|
||||
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
|
||||
String responseData = apiResponse.get("data").toString();
|
||||
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
|
||||
LOGGER.info("Response" + apiResponse);
|
||||
String responseData = apiResponse.get(BBPSConstant.RESPONSE_DATA_KEY).toString();
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
@@ -688,12 +724,12 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), // message
|
||||
String.valueOf(dataMap.get("status")), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode (int)
|
||||
String.valueOf(dataMap.get("remarks")));
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode (int)
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
|
||||
}
|
||||
|
||||
ChannelsListResponse responseWrapper = objectMapper.convertValue(dataMap, ChannelsListResponse.class);
|
||||
@@ -709,7 +745,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
|
||||
}
|
||||
@@ -717,7 +753,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
public ResponseModel fetchPlanByCategories(PlanRequest requestModel) {
|
||||
|
||||
String apiName = "FetchPlanByCategories";
|
||||
String apiName = BBPSConstant.API_FETCH_PLAN_BY_CATEGORIES;
|
||||
String requestId = requestModel.getReqId();
|
||||
String mid = requestModel.getMid();
|
||||
|
||||
@@ -737,14 +773,16 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
// Convert request to JSON and create inbound & outbound logs
|
||||
String requestJson = helper.convertObjectToJson(requestModel);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "GET",
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), BBPSConstant.HTTP_POST,
|
||||
requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, "GET", null);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, BBPSConstant.HTTP_GET, null);
|
||||
try {
|
||||
LOGGER.info("[{}] Calling Master API | URL={} | Method=GET", apiName, url);
|
||||
Map<String, String> apiResponse = httpService.getRequest(url);
|
||||
String responseData = apiResponse.get("data");
|
||||
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
|
||||
|
||||
String responseData = apiResponse.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Response Data: {}", responseData);
|
||||
|
||||
// Update outbound log with response
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
@@ -753,12 +791,13 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
// Failure response
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
String.valueOf(dataMap.get("remarks")));
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)),
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)),
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))),
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
|
||||
}
|
||||
|
||||
// Success response
|
||||
@@ -777,7 +816,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
@@ -785,7 +824,8 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
@Override
|
||||
public ResponseModel getTicketDispositions(DispositionRequest dispositionDetailRequest) {
|
||||
|
||||
String apiName = "GetTicketDispositionDetails";
|
||||
|
||||
String apiName = BBPSConstant.API_GET_TICKET_DISPOSITIONS;
|
||||
String requestId = dispositionDetailRequest.getReqId();
|
||||
String mid = dispositionDetailRequest.getMid();
|
||||
|
||||
@@ -795,28 +835,27 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.TICKET_DISPOSTION_URL;
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
|
||||
dispositionDetailRequest.getMid(), "GET", "N/A");
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET",
|
||||
dispositionDetailRequest.getMid());
|
||||
dispositionDetailRequest.getMid(), BBPSConstant.HTTP_GET, "N/A");
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
|
||||
|
||||
try {
|
||||
LOGGER.info("[{}] Calling External API | URL={} | Method=GET", apiName, fullUrl);
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||
String responseData = responseMap.get("data");
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
|
||||
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), // message
|
||||
String.valueOf(dataMap.get("status")), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode (int)
|
||||
String.valueOf(dataMap.get("remarks")));
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode (int)
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
|
||||
}
|
||||
|
||||
TicketDispositionResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||
@@ -836,9 +875,9 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
return responseModel;
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||
@@ -36,6 +35,7 @@ import com.billpaymentservice.bbps.repository.PaymentRepository;
|
||||
import com.billpaymentservice.bbps.repository.TransactionMasterRepository;
|
||||
import com.billpaymentservice.bbps.service.PaymentService;
|
||||
import com.billpaymentservice.bbps.util.BBPSConstant;
|
||||
import com.billpaymentservice.bbps.util.BillerMapperHelper;
|
||||
import com.billpaymentservice.bbps.util.EntityRelationshipUtil;
|
||||
import com.billpaymentservice.bbps.util.Helper;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
@@ -45,487 +45,343 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
@Service
|
||||
public class PaymentServiceImpl implements PaymentService {
|
||||
@Value("${payment.data.url}")
|
||||
private String paymentUrl;
|
||||
|
||||
private final BharatConnectMasterRepository beneficiaryDetailsRepository;
|
||||
private final HttpService httpService;
|
||||
private final Helper helper;
|
||||
private final PaymentRepository paymentRepository;
|
||||
private final InboundTraceLogRepository inboundTraceLogRepository;
|
||||
private final OutboundTraceLogRepository outboundTraceLogRepository;
|
||||
private final PaymentIntiateRepository paymentIntiateRepository;
|
||||
private final TransactionMasterRepository transactionMasterRepository;
|
||||
private final AgentFundTransferRepository agentFundTransferRepository;
|
||||
private final BillerMapperHelper mapperHelper;
|
||||
// Shared reusable instances
|
||||
private final ObjectMapper objectMapper;
|
||||
private final ModelMapper modelMapper;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PaymentServiceImpl.class);
|
||||
|
||||
public PaymentServiceImpl(BharatConnectMasterRepository beneficiaryDetailsRepository, HttpService httpService,
|
||||
Helper helper, PaymentRepository paymentRepository, InboundTraceLogRepository inboundTraceLogRepository,
|
||||
OutboundTraceLogRepository outboundTraceLogRepository, PaymentIntiateRepository paymentIntiateRepository,
|
||||
TransactionMasterRepository transactionMasterRepository,
|
||||
AgentFundTransferRepository agentFundTransferRepository,
|
||||
BillerMapperHelper mapperHelper) {
|
||||
this.beneficiaryDetailsRepository = beneficiaryDetailsRepository;
|
||||
this.httpService = httpService;
|
||||
this.helper = helper;
|
||||
this.paymentRepository = paymentRepository;
|
||||
this.inboundTraceLogRepository = inboundTraceLogRepository;
|
||||
this.outboundTraceLogRepository = outboundTraceLogRepository;
|
||||
this.paymentIntiateRepository = paymentIntiateRepository;
|
||||
this.transactionMasterRepository = transactionMasterRepository;
|
||||
this.agentFundTransferRepository = agentFundTransferRepository;
|
||||
this.mapperHelper = mapperHelper;
|
||||
|
||||
this.objectMapper = new ObjectMapper();
|
||||
this.objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
|
||||
this.modelMapper = new ModelMapper();
|
||||
this.modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel initiatePayment(BillPaymentRequest billPaymentRequest) {
|
||||
String apiName = BBPSConstant.API_INITIATE_PAYMENT;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String requestId = billPaymentRequest.getReqId();
|
||||
String url = paymentUrl + BBPSConstant.PAYMENT_URL;
|
||||
billPaymentRequest.setClientReqId(txnId);
|
||||
LOGGER.info("Initiating payment for reqId={} and txnId={}", requestId, txnId);
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
|
||||
BillPaymentForwardRequest forwardReq = mapperHelper.billPaymentForwardRequest(billPaymentRequest);
|
||||
String forwardjson = helper.convertObjectToJson(forwardReq);
|
||||
String requestJson = helper.convertObjectToJson(billPaymentRequest);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, billPaymentRequest.getMid(), BBPSConstant.HTTP_POST, requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, BBPSConstant.HTTP_POST, forwardjson);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling BBPS payment URL: {}", url);
|
||||
Map<String, String> responseMap = httpService.postRequest(url, forwardjson, headers);
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Payment API Response: {}", responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
if (responseData == null || responseData.isEmpty()) {
|
||||
helper.updateInboundLogFailure(inboundLog, BBPSConstant.EMPTY_RESPONSE_FROM_BBPS, BBPSConstant.FAILED_STR);
|
||||
LOGGER.warn("Empty response received from BBPS for txnId={}", txnId);
|
||||
throw new CustomException(BBPSConstant.EMPTY_RESPONSE_FROM_BBPS);
|
||||
}
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERIC_KEY)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_STRUCTURE);
|
||||
LOGGER.warn("Invalid response structure received for txnId={}", txnId);
|
||||
throw new CustomException(BBPSConstant.INVALID_STRUCTURE);
|
||||
}
|
||||
|
||||
BillPaymentResponse billPaymentResponse = objectMapper.convertValue(dataMap, BillPaymentResponse.class);
|
||||
GeneralResp generalResponse = billPaymentResponse.getGenericResponse();
|
||||
|
||||
BillPayment entity = modelMapper.map(billPaymentResponse, BillPayment.class);
|
||||
paymentRepository.save(entity);
|
||||
LOGGER.info("BillPayment entity saved successfully for txnId={}", txnId);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResponse.getStatus());
|
||||
PaymentInitiate paymentInitiate = new PaymentInitiate();
|
||||
paymentInitiate.setTxnId(txnId);
|
||||
paymentInitiate.setReqId(requestId);
|
||||
paymentInitiate.setBankTxnId(billPaymentResponse.getTxnId());
|
||||
paymentInitiate.setStatus(billPaymentResponse.getStatus());
|
||||
paymentIntiateRepository.save(paymentInitiate);
|
||||
LOGGER.info("PaymentInitiate entry saved successfully for txnId={}", txnId);
|
||||
|
||||
TransactionStatusRequest transactionStatusRequest = new TransactionStatusRequest();
|
||||
transactionStatusRequest.setTxnId(billPaymentResponse.getTxnId());
|
||||
transactionStatusRequest.setReqId(requestId);
|
||||
|
||||
try {
|
||||
Thread.sleep((long) BBPSConstant.PAYMENT_STATUS_DELAY_MS);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
LOGGER.warn("Thread interrupted during payment delay: {}", e.getMessage());
|
||||
}
|
||||
LOGGER.info("Checking transaction status for txnId={}", billPaymentResponse.getTxnId());
|
||||
return checkTrasactionStatus(transactionStatusRequest, inboundLog);
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("JSON Parsing Error in initiatePayment: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest, InboundTraceLog inboundLog) {
|
||||
String apiName = BBPSConstant.API_CHECK_TRANSACTION_STATUS;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String requestId = transactionStatusRequest.getReqId();
|
||||
|
||||
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
|
||||
|
||||
LOGGER.info("Checking transaction status (internal) for txnId={} and reqId={}", transactionStatusRequest.getTxnId(), requestId);
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, BBPSConstant.HTTP_GET, null);
|
||||
|
||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Transaction status response: {}", responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
try {
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
LOGGER.warn("Invalid transaction status response for txnId={}", transactionStatusRequest.getTxnId());
|
||||
throw new CustomException(
|
||||
String.valueOf(dataMap.get("message")),
|
||||
String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
String.valueOf(dataMap.get("remarks"))
|
||||
);
|
||||
}
|
||||
|
||||
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
LOGGER.info("Transaction status received: {}", generalResp.getStatus());
|
||||
|
||||
TransactionMaster transactionMaster = modelMapper.map(responseWrapper.getTransactionDAO(), TransactionMaster.class);
|
||||
transactionMaster.setTxnId(txnId);
|
||||
transactionMaster.setReqId(transactionStatusRequest.getReqId());
|
||||
EntityRelationshipUtil.linkTransactionMasterRelationships(transactionMaster);
|
||||
transactionMasterRepository.save(transactionMaster);
|
||||
LOGGER.info("TransactionMaster saved successfully for txnId={}", txnId);
|
||||
|
||||
AgentFundTransfer agentFundTransfer = modelMapper.map(responseWrapper.getAgentFundTransfer(), AgentFundTransfer.class);
|
||||
agentFundTransfer.setTxnId(txnId);
|
||||
agentFundTransfer.setReqId(transactionStatusRequest.getReqId());
|
||||
agentFundTransfer.setTransactionMasterId(transactionMaster.getBankTxnId());
|
||||
agentFundTransferRepository.save(agentFundTransfer);
|
||||
LOGGER.info("AgentFundTransfer entry saved successfully for txnId={}", txnId);
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(
|
||||
generalResp.getMessage(),
|
||||
generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()),
|
||||
responseWrapper
|
||||
);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
return responseModel;
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing transaction status JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest) {
|
||||
helper.validateMerchant(transactionStatusRequest.getMid());
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = BBPSConstant.API_CHECK_TRANSACTION_PUBLIC;
|
||||
String requestId = transactionStatusRequest.getReqId();
|
||||
String requestJson = helper.convertObjectToJson(transactionStatusRequest);
|
||||
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
|
||||
|
||||
LOGGER.info("Checking transaction status (public) for txnId={} and reqId={}", transactionStatusRequest.getTxnId(), requestId);
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, transactionStatusRequest.getMid(), BBPSConstant.HTTP_POST, requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, BBPSConstant.HTTP_GET, null);
|
||||
|
||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Transaction status response data: {}", responseData);
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
try {
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
LOGGER.warn("Invalid transaction status response for txnId={} from BBPS", transactionStatusRequest.getTxnId());
|
||||
throw new CustomException(
|
||||
String.valueOf(dataMap.get("message")),
|
||||
String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
String.valueOf(dataMap.get("remarks"))
|
||||
);
|
||||
}
|
||||
|
||||
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
|
||||
String status = generalResp.getStatus();
|
||||
LOGGER.info("Current transaction status: {}", status);
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(
|
||||
generalResp.getMessage(),
|
||||
generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()),
|
||||
responseWrapper
|
||||
);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
return responseModel;
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel checkTrasactionStatusByClientReqId(TrasactionStatusByClientReqIdRequest transactionStatusRequest) {
|
||||
|
||||
helper.validateMerchant(transactionStatusRequest.getMid());
|
||||
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = BBPSConstant.API_CHECK_BY_CLIENT_REQ_ID;
|
||||
String requestId = transactionStatusRequest.getReqId();
|
||||
String clientReqId = transactionStatusRequest.getClientReqId();
|
||||
String requestJson = helper.convertObjectToJson(transactionStatusRequest);
|
||||
|
||||
LOGGER.info("Checking transaction status for clientReqId={} and reqId={}", clientReqId, requestId);
|
||||
|
||||
Optional<PaymentInitiate> paymentInitiate = paymentIntiateRepository.findByReqId(clientReqId);
|
||||
if (paymentInitiate.isEmpty()) {
|
||||
throw new CustomException(BBPSConstant.NO_BILL_FOUND);
|
||||
}
|
||||
|
||||
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_BY_CLIENT_REQ_ID_URL + paymentInitiate.get().getTxnId();
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(
|
||||
requestId, txnID, apiName, transactionStatusRequest.getMid(), BBPSConstant.HTTP_POST, requestJson);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(
|
||||
txnID, requestId, apiName, url, BBPSConstant.HTTP_GET, null);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling BBPS Transaction Status API URL={}", url);
|
||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Transaction Status Response: {}", responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(
|
||||
responseData, new TypeReference<Map<String, Object>>() {});
|
||||
|
||||
@Value("${payment.data.url}")
|
||||
private String paymentUrl;
|
||||
|
||||
private final BharatConnectMasterRepository beneficiaryDetailsRepository;
|
||||
private final HttpService httpService;
|
||||
private final Helper helper;
|
||||
private final PaymentRepository paymentRepository;
|
||||
private final InboundTraceLogRepository inboundTraceLogRepository;
|
||||
private final OutboundTraceLogRepository outboundTraceLogRepository;
|
||||
private final PaymentIntiateRepository paymentIntiateRepository;
|
||||
private final TransactionMasterRepository transactionMasterRepository;
|
||||
private final AgentFundTransferRepository agentFundTransferRepository;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PaymentServiceImpl.class);
|
||||
|
||||
public PaymentServiceImpl(BharatConnectMasterRepository beneficiaryDetailsRepository, HttpService httpService,
|
||||
Helper helper, PaymentRepository paymentRepository, InboundTraceLogRepository inboundTraceLogRepository,
|
||||
OutboundTraceLogRepository outboundTraceLogRepository, PaymentIntiateRepository paymentIntiateRepository,
|
||||
TransactionMasterRepository transactionMasterRepository,
|
||||
AgentFundTransferRepository agentFundTransferRepository) {
|
||||
this.beneficiaryDetailsRepository = beneficiaryDetailsRepository;
|
||||
this.httpService = httpService;
|
||||
this.helper = helper;
|
||||
this.paymentRepository = paymentRepository;
|
||||
this.inboundTraceLogRepository = inboundTraceLogRepository;
|
||||
this.outboundTraceLogRepository = outboundTraceLogRepository;
|
||||
this.paymentIntiateRepository = paymentIntiateRepository;
|
||||
this.transactionMasterRepository = transactionMasterRepository;
|
||||
this.agentFundTransferRepository = agentFundTransferRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel initiatePayment(BillPaymentRequest billPaymentRequest) {
|
||||
String apiName = "InitiatePayment";
|
||||
String requestId = billPaymentRequest.getReqId();
|
||||
String mid = billPaymentRequest.getMid();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={}", apiName, requestId, mid);
|
||||
helper.validateMerchant(mid);
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String url = paymentUrl + BBPSConstant.PAYMENT_URL;
|
||||
billPaymentRequest.setClientReqId(txnId);
|
||||
LOGGER.info("Initiating payment for reqId={} and txnId={}", requestId, txnId);
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
BillPaymentForwardRequest forwardReq = helper.billPaymentForwardRequest(billPaymentRequest);
|
||||
|
||||
String forwardjson = helper.convertObjectToJson(forwardReq);
|
||||
|
||||
String requestJson = helper.convertObjectToJson(billPaymentRequest);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, billPaymentRequest.getMid(),
|
||||
"POST", requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, "POST", forwardjson);
|
||||
|
||||
try {
|
||||
LOGGER.info("[{}] Calling BBPS Payment API | url={}", apiName, url);
|
||||
Map<String, String> responseMap = httpService.postRequest(url, forwardjson, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("[{}] Raw Payment API Response | reqId={}", apiName, requestId);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
if (responseData == null || responseData.isEmpty()) {
|
||||
helper.updateInboundLogFailure(inboundLog, "Empty response from BBPS", "FAILED");
|
||||
LOGGER.warn("Empty response received from BBPS for txnId={}", txnId);
|
||||
throw new CustomException("Empty response from BBPS server");
|
||||
}
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_STRUCTURE");
|
||||
LOGGER.warn("Invalid response structure received for txnId={}", txnId);
|
||||
throw new CustomException("Invalid response structure from BBPS");
|
||||
}
|
||||
|
||||
BillPaymentResponse billPaymentResponse = objectMapper.convertValue(dataMap, BillPaymentResponse.class);
|
||||
GeneralResp generalResponse = billPaymentResponse.getGenericResponse();
|
||||
|
||||
ModelMapper mapper = new ModelMapper();
|
||||
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||
BillPayment entity = mapper.map(billPaymentResponse, BillPayment.class);
|
||||
paymentRepository.save(entity);
|
||||
LOGGER.info("BillPayment entity saved successfully for txnId={}", txnId);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResponse.getStatus());
|
||||
PaymentInitiate paymentInitiate = new PaymentInitiate();
|
||||
paymentInitiate.setTxnId(txnId);
|
||||
paymentInitiate.setReqId(requestId);
|
||||
paymentInitiate.setBankTxnId(billPaymentResponse.getTxnId());
|
||||
paymentInitiate.setStatus(billPaymentResponse.getStatus());
|
||||
paymentIntiateRepository.save(paymentInitiate);
|
||||
LOGGER.info("PaymentInitiate entry saved successfully for txnId={}", txnId);
|
||||
|
||||
LOGGER.info("[{}] Checking Transaction Status for bankTxnId={}", apiName, billPaymentResponse.getTxnId());
|
||||
TransactionStatusRequest transactionStatusRequest = new TransactionStatusRequest();
|
||||
transactionStatusRequest.setTxnId(billPaymentResponse.getTxnId());
|
||||
transactionStatusRequest.setReqId(requestId);
|
||||
|
||||
try {
|
||||
Thread.sleep(9000);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
LOGGER.warn("Thread interrupted during payment delay: {}", e.getMessage());
|
||||
}
|
||||
LOGGER.info("Checking transaction status for txnId={}", billPaymentResponse.getTxnId());
|
||||
return checkTrasactionStatus(transactionStatusRequest, inboundLog);
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("JSON Parsing Error in initiatePayment: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest,
|
||||
InboundTraceLog inboundLog) {
|
||||
String apiName = "CheckTransactionStatus";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String requestId = transactionStatusRequest.getReqId();
|
||||
|
||||
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
|
||||
|
||||
LOGGER.info("Checking transaction status (internal) for txnId={} and reqId={}",
|
||||
transactionStatusRequest.getTxnId(), requestId);
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, "GET", null);
|
||||
|
||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("Transaction status response: {}", responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
try {
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
LOGGER.warn("Invalid transaction status response for txnId={}", transactionStatusRequest.getTxnId());
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
String.valueOf(dataMap.get("remarks")));
|
||||
}
|
||||
|
||||
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||
TransactionStatusResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
LOGGER.info("Transaction status received: {}", generalResp.getStatus());
|
||||
|
||||
ModelMapper mapper = new ModelMapper();
|
||||
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||
TransactionMaster transactionMaster = mapper.map(responseWrapper.getTransactionDAO(),
|
||||
TransactionMaster.class);
|
||||
transactionMaster.setTxnId(txnId);
|
||||
transactionMaster.setReqId(transactionStatusRequest.getReqId());
|
||||
EntityRelationshipUtil.linkTransactionMasterRelationships(transactionMaster);
|
||||
transactionMasterRepository.save(transactionMaster);
|
||||
LOGGER.info("TransactionMaster saved successfully for txnId={}", txnId);
|
||||
|
||||
AgentFundTransfer agentFundTransfer = mapper.map(responseWrapper.getAgentFundTransfer(),
|
||||
AgentFundTransfer.class);
|
||||
agentFundTransfer.setTxnId(txnId);
|
||||
agentFundTransfer.setReqId(transactionStatusRequest.getReqId());
|
||||
agentFundTransfer.setTransactionMasterId(transactionMaster.getBankTxnId());
|
||||
agentFundTransferRepository.save(agentFundTransfer);
|
||||
LOGGER.info("AgentFundTransfer entry saved successfully for txnId={}", txnId);
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
return responseModel;
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing transaction status JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest) {
|
||||
helper.validateMerchant(transactionStatusRequest.getMid());
|
||||
String apiName = "checkTrasactionStatus";
|
||||
String requestId = transactionStatusRequest.getReqId();
|
||||
String mid = transactionStatusRequest.getMid();
|
||||
String bankTxnId = transactionStatusRequest.getTxnId();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | bankTxnId={}", apiName, requestId, mid, bankTxnId);
|
||||
|
||||
helper.validateMerchant(mid);
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String requestJson = helper.convertObjectToJson(transactionStatusRequest);
|
||||
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
|
||||
|
||||
LOGGER.info("Checking transaction status (public) for txnId={} and reqId={}",
|
||||
transactionStatusRequest.getTxnId(), requestId);
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
|
||||
transactionStatusRequest.getMid(), "POST", requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, "GET", null);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("Transaction status response data: {}", responseData);
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
try {
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
||||
LOGGER.warn("Invalid transaction status response for txnId={} from BBPS",
|
||||
transactionStatusRequest.getTxnId());
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
String.valueOf(dataMap.get("remarks")));
|
||||
}
|
||||
|
||||
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||
TransactionStatusResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
|
||||
String status = generalResp.getStatus();
|
||||
LOGGER.info("Current transaction status: {}", status);
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
return responseModel;
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel checkTrasactionStatusByClientReqId(
|
||||
TrasactionStatusByClientReqIdRequest transactionStatusRequest) {
|
||||
String apiName = "checkTrasactionStatusbyClientReqId";
|
||||
String requestId = transactionStatusRequest.getReqId();
|
||||
String clientReqId = transactionStatusRequest.getClientReqId();
|
||||
String mid = transactionStatusRequest.getMid();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | clientReqId={}", apiName, requestId, mid, clientReqId);
|
||||
|
||||
helper.validateMerchant(transactionStatusRequest.getMid());
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String requestJson = helper.convertObjectToJson(transactionStatusRequest);
|
||||
|
||||
LOGGER.info("Checking transaction status for clientReqId={} and reqId={}", clientReqId, requestId);
|
||||
|
||||
// Fetch Txn from DB
|
||||
Optional<PaymentInitiate> paymentInitiate = paymentIntiateRepository.findByReqId(clientReqId);
|
||||
if (paymentInitiate.isEmpty()) {
|
||||
throw new CustomException("No Transaction Found for given Client Req Id");
|
||||
}
|
||||
|
||||
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_BY_CLIENT_REQ_ID_URL
|
||||
+ paymentInitiate.get().getTxnId();
|
||||
|
||||
LOGGER.info("[{}] BBPS URL={}", apiName, url);
|
||||
// Prepare headers
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
// 🔵 Create Inbound + Outbound Logs
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
|
||||
transactionStatusRequest.getMid(), "POST", requestJson);
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, "GET", null);
|
||||
LOGGER.warn("Invalid transaction status response for clientReqId={} | Response={}",
|
||||
clientReqId, responseData);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
throw new CustomException(
|
||||
String.valueOf(dataMap.get("message")),
|
||||
String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
String.valueOf(dataMap.get("remarks"))
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling BBPS Transaction Status API URL={}", url);
|
||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||
TransactionStatusResponse responseWrapper =
|
||||
objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
|
||||
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.debug("[{}] Raw Response | reqId={} | data={}", apiName, requestId, responseData);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
// Parse response
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
LOGGER.info("Transaction Status for clientReqId={} => {}", clientReqId, generalResp.getStatus());
|
||||
|
||||
// Validate response
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
LOGGER.warn("[{}] INVALID RESPONSE | reqId={} | response={}", apiName, requestId, responseData);
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
return new ResponseModel(
|
||||
generalResp.getMessage(),
|
||||
generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()),
|
||||
responseWrapper
|
||||
);
|
||||
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing JSON in transaction status API: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
|
||||
LOGGER.warn("Invalid transaction status response for clientReqId={} | Response={}", clientReqId,
|
||||
responseData);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
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")));
|
||||
}
|
||||
@Override
|
||||
public ResponseModel handlePaymentIntiateCallback(TransactionStatusResponse transactionStatusResponse) {
|
||||
|
||||
// Convert into proper DTO
|
||||
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||
TransactionStatusResponse.class);
|
||||
LOGGER.info("Recived Call Back from FetchBillValidateResponse: {}", transactionStatusResponse);
|
||||
if (transactionStatusResponse.getGeneralResp().getStatusCode().equals(BBPSConstant.SUCCESS_CODE_STR)) {
|
||||
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
} else {
|
||||
LOGGER.info("Bill Fetch Callback Failed with Status: {}", transactionStatusResponse.getGeneralResp().getStatus());
|
||||
|
||||
LOGGER.info("Transaction Status for clientReqId={} => {}", clientReqId, generalResp.getStatus());
|
||||
}
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing JSON in transaction status API: {}", e.getMessage(), e);
|
||||
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
return new ResponseModel(BBPSConstant.CALLBACK_RECEIVED_SUCCESS,
|
||||
BBPSConstant.SUCCESS_CODE_STR,
|
||||
BBPSConstant.HTTP_OK_INT,
|
||||
"");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* PollBack logic for the fetchTxnByTxnId API
|
||||
*
|
||||
* @Override public ResponseModel fetchTxnByTxnId(BillFetchByBillIdRequest
|
||||
* billFetchByBillIdRequest) {
|
||||
*
|
||||
* String billId = billFetchByBillIdRequest.getBillId(); String fullUrl =
|
||||
* agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID+billId;
|
||||
* System.out.print(fullUrl);
|
||||
*
|
||||
* BeneficiaryDetails
|
||||
* headersData=beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
*
|
||||
* HttpHeaders headers = new HttpHeaders();
|
||||
* headers.set("x-digiledge-key",headersData.getXDigiledgeKey());
|
||||
* headers.set("agentId", headersData.getAgentId()); headers.set("tenantId",
|
||||
* headersData.getTenantId());
|
||||
* headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
*
|
||||
* Map<String, String> responseMap = httpService.getRequest(fullUrl,headers);
|
||||
* String responseData = responseMap.get("data"); log.info("data is :{}",
|
||||
* responseData);
|
||||
*
|
||||
*
|
||||
* ObjectMapper objectMapper = new ObjectMapper();
|
||||
*
|
||||
* try { Map<String, Object> dataMap = objectMapper.readValue(responseData, new
|
||||
* TypeReference<Map<String, Object>>() { }); if
|
||||
* (!dataMap.containsKey("genericResponse")) { throw new
|
||||
* CustomException(String.valueOf(dataMap.get("message")), // message
|
||||
* String.valueOf(dataMap.get("status")), // status
|
||||
* Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode
|
||||
* (int) String.valueOf(dataMap.get("remarks")) ); }
|
||||
*
|
||||
* BillDataResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||
* BillDataResponse.class);
|
||||
*
|
||||
* GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||
*
|
||||
* ResponseModel responseModel=new ResponseModel( generalResp.getMessage(),
|
||||
* generalResp.getStatus(), Integer.parseInt(generalResp.getStatusCode()),
|
||||
* responseWrapper);
|
||||
*
|
||||
* return responseModel;
|
||||
*
|
||||
* } catch (JsonProcessingException e) {
|
||||
* LOGGER.error("Error parsing responseData JSON: {}", e.getMessage()); throw
|
||||
* new CustomException("Invalid JSON received from API"); }
|
||||
*
|
||||
* }
|
||||
*/
|
||||
|
||||
/*
|
||||
* public ResponseModel checkTrasactionStatus(TransactionStatusRequest
|
||||
* transactionStatusRequest,InboundTraceLog inboundLog) { String apiName =
|
||||
* "CheckTransactionStatus"; String txnId = helper.generateTxnId(15); //our
|
||||
* genrated txnId String requestId = transactionStatusRequest.getReqId(); String
|
||||
* url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL +
|
||||
* transactionStatusRequest.getTxnId(); ;
|
||||
*
|
||||
* BharatConnectMaster headersData =
|
||||
* beneficiaryDetailsRepository.findByOrgId("ORG001"); HttpHeaders headers = new
|
||||
* HttpHeaders(); headers.set("x-digiledge-key",
|
||||
* headersData.getXDigiledgeKey()); headers.set("agentId",
|
||||
* headersData.getAgentId()); headers.set("tenantId",
|
||||
* headersData.getTenantId());
|
||||
* headers.setContentType(MediaType.APPLICATION_JSON); ObjectMapper objectMapper
|
||||
* = new ObjectMapper();
|
||||
*
|
||||
* OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId,
|
||||
* apiName, url, "GET", null);
|
||||
*
|
||||
* long startTime = System.currentTimeMillis(); long maxWaitTimeMs = 40000; long
|
||||
* intervalMs = 5000;
|
||||
*
|
||||
* while (true) { Map<String, String> responseMap = httpService.getRequest(url,
|
||||
* headers); String responseData = responseMap.get("data");
|
||||
* LOGGER.info("Transaction status response: {}", responseData);
|
||||
*
|
||||
* helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
*
|
||||
* try { Map<String, Object> dataMap = objectMapper.readValue(responseData, new
|
||||
* TypeReference<Map<String, Object>>() {});
|
||||
*
|
||||
* if (!dataMap.containsKey("generalResp")) {
|
||||
* helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
* throw new CustomException( String.valueOf(dataMap.get("message")),
|
||||
* String.valueOf(dataMap.get("status")),
|
||||
* Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||
* String.valueOf(dataMap.get("remarks")) ); }
|
||||
*
|
||||
* TransactionStatusResponse responseWrapper =
|
||||
* objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
|
||||
* GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
*
|
||||
* String status = generalResp.getStatus();
|
||||
* LOGGER.info("Current transaction status: {}", status);
|
||||
*
|
||||
* if ("INPROGRESS".equalsIgnoreCase(status)) { if (System.currentTimeMillis() -
|
||||
* startTime > maxWaitTimeMs) { helper.updateInboundLogFailure(inboundLog,
|
||||
* "Timeout after 40 seconds", "FAILED"); throw new
|
||||
* CustomException("Timeout waiting for transaction completion", "FAILED", 408,
|
||||
* "Transaction still in progress"); }
|
||||
*
|
||||
* Thread.sleep(intervalMs); continue; }
|
||||
*
|
||||
* ResponseModel responseModel = new ResponseModel( generalResp.getMessage(),
|
||||
* generalResp.getStatus(), Integer.parseInt(generalResp.getStatusCode()),
|
||||
* responseWrapper );
|
||||
*
|
||||
* helper.updateInboundLogSuccess(inboundLog, responseData,
|
||||
* generalResp.getStatus()); return responseModel;
|
||||
*
|
||||
* } catch (JsonProcessingException e) {
|
||||
* LOGGER.error("Error parsing transaction status JSON: {}", e.getMessage());
|
||||
* helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
* throw new CustomException("Invalid JSON received from API"); } catch
|
||||
* (InterruptedException e) { Thread.currentThread().interrupt();
|
||||
* helper.updateInboundLogFailure(inboundLog, e.getMessage(), "INTERRUPTED");
|
||||
* throw new CustomException("Thread interrupted during transaction check"); } }
|
||||
* }
|
||||
*
|
||||
*
|
||||
*/
|
||||
@@ -59,4 +59,85 @@ public class BBPSConstant {
|
||||
public static final String ADD_COMPLAIN_ENDPOINT = "/couapp/ticket/raise";
|
||||
public static final String VIEW_ALL_COMPLAINTS_BASE = "/couapp/tickets";
|
||||
|
||||
}
|
||||
// New centralized string/constants used across services
|
||||
public static final String API_INITIATE_BILL_FETCH = "InitiateBillFetch";
|
||||
public static final String API_FETCH_BILL_BY_ID = "FetchBillById";
|
||||
public static final String API_INITIATE_BILL_VALIDATE = "InitiateBillValidate";
|
||||
public static final String API_FETCH_BILL_VALIDATE_BY_CLIENT_ID = "FetchBillValidateByClientIdRequest";
|
||||
public static final String API_FETCH_BILL_BY_CLIENT_ID = "FetchBillByClientIdRequest";
|
||||
|
||||
public static final String HTTP_POST = "POST";
|
||||
public static final String HTTP_GET = "GET";
|
||||
|
||||
public static final String INVALID_RESPONSE = "INVALID_RESPONSE";
|
||||
public static final String JSON_ERROR = "JSON_ERROR";
|
||||
|
||||
public static final String CALLBACK_RECEIVED_SUCCESS = "CallBack Recieved Successfully";
|
||||
public static final String NO_BILL_FOUND = "No Bill Found for given Client Req Id";
|
||||
|
||||
public static final String SUCCESS_CODE_STR = "200";
|
||||
|
||||
// Added constants referenced by ComplainServiceImpl
|
||||
public static final String ORG_ID = "ORG001";
|
||||
|
||||
public static final String API_ADD_COMPLAIN = "ADD_COMPLAIN";
|
||||
public static final String API_COMPLAINT_STATUS = "COMPLAINT_STATUS";
|
||||
public static final String API_VIEW_COMPLAINT_HISTORY = "View_Complaint_History";
|
||||
public static final String API_VIEW_COMPLAINT_BY_ID = "View_Complaint_By_ID";
|
||||
public static final String API_GET_ALL_MASTER_OPTIONS = "View All Options Fetch By Id";
|
||||
public static final String API_CHECK_TXN_STATUS = "CheckTxnStatus";
|
||||
public static final String API_VIEW_ALL_COMPLAINTS_BY_STATUS = "View_All_Complaint_By_Status_Type";
|
||||
|
||||
// API names used by MasterDataServiceImpl
|
||||
public static final String API_GET_MASTER_DATA = "GetMasterData";
|
||||
public static final String API_GET_BILLER_BY_ID = "GetBillerByBillerId";
|
||||
public static final String API_GET_CUSTOMER_PARAM_BY_BILLER_ID = "GetCustomerParamByBillerId";
|
||||
public static final String API_FETCH_MASTER_DATA_CATEGORY_WISE = "FetchMasterDataCategoryWise";
|
||||
public static final String API_FETCH_CUSTOMER_PARAM_GROUP = "FetchCustomerParamGroup";
|
||||
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_INITIATING_CHANNEL = "FetchInitiatingChannel";
|
||||
public static final String API_FETCH_PLAN_BY_CATEGORIES = "FetchPlanByCategories";
|
||||
public static final String API_GET_TICKET_DISPOSITIONS = "GetTicketDispositionDetails";
|
||||
|
||||
// Payment related API names
|
||||
public static final String API_INITIATE_PAYMENT = "InitiatePayment";
|
||||
public static final String API_CHECK_TRANSACTION_STATUS = "CheckTransactionStatus";
|
||||
public static final String API_CHECK_TRANSACTION_PUBLIC = "checkTrasactionStatus";
|
||||
public static final String API_CHECK_BY_CLIENT_REQ_ID = "checkTrasactionStatusbyClientReqId";
|
||||
|
||||
// Response and helper keys (already existing ones kept)
|
||||
public static final String RESPONSE_GENERIC_KEY = "genericResponse";
|
||||
|
||||
// Common messages used in PaymentServiceImpl
|
||||
public static final String EMPTY_RESPONSE_FROM_BBPS = "Empty response from BBPS";
|
||||
public static final String INVALID_STRUCTURE = "INVALID_STRUCTURE";
|
||||
public static final String FAILED_STR = "FAILED";
|
||||
|
||||
public static final int HTTP_OK_INT = 200;
|
||||
public static final int HTTP_NOT_FOUND = 404;
|
||||
public static final int HTTP_INTERNAL_SERVER_ERROR = 500;
|
||||
|
||||
// Response and helper keys
|
||||
public static final String HTTP_SERVICE_ERROR_PREFIX = "HttpService Error";
|
||||
public static final String RESPONSE_DATA_KEY = "data";
|
||||
public static final String RESPONSE_MESSAGE_KEY = "message";
|
||||
public static final String RESPONSE_STATUS_KEY = "status";
|
||||
public static final String RESPONSE_STATUSCODE_KEY = "statusCode";
|
||||
public static final String RESPONSE_REMARKS_KEY = "remarks";
|
||||
public static final String RESPONSE_GENERAL_RESP = "generalResp";
|
||||
public static final String SUCCESS_RESPONSE = "SUCCESS";
|
||||
|
||||
// Newly added constants used by ComplainServiceImpl
|
||||
public static final String DB_OPTIONS = "/db/options"; // used as a logical URL/identifier for master options
|
||||
public static final String NULL_DATA_FROM_DB = "NULL_DATA_FROM_DB";
|
||||
public static final String NO_MASTER_FIELDS_FOUND = "No master fields found";
|
||||
public static final String ALL_MASTER_FIELDS_FETCH = "All master fields fetched successfully";
|
||||
public static final String SOMETHING_WENT_WRONG = "Something went wrong";
|
||||
|
||||
// Timing/delay constants (milliseconds)
|
||||
public static final long BILL_FETCH_DELAY_MS = 5000L; // used after initiate bill fetch
|
||||
public static final long BILL_VALIDATE_DELAY_MS = 12000L; // used after initiate bill validate
|
||||
public static final long PAYMENT_STATUS_DELAY_MS = 9000L; // used after initiate payment
|
||||
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.modelmapper.ModelMapper;
|
||||
@@ -14,6 +15,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.AdditionalInfoBillDTO;
|
||||
import com.billpaymentservice.bbps.dto.AmountOptionDTO;
|
||||
import com.billpaymentservice.bbps.dto.BillAdditionalInfoDTO;
|
||||
import com.billpaymentservice.bbps.dto.BillCustomerParamsDTO;
|
||||
@@ -21,6 +23,7 @@ import com.billpaymentservice.bbps.dto.BillerIconDTO;
|
||||
import com.billpaymentservice.bbps.dto.CheckClientBillerResponseDTO;
|
||||
import com.billpaymentservice.bbps.dto.ComplaintHistoryDTO;
|
||||
import com.billpaymentservice.bbps.dto.ContactMaster;
|
||||
import com.billpaymentservice.bbps.dto.CustomerParamDAO;
|
||||
import com.billpaymentservice.bbps.dto.CustomerParamGroupsDTO;
|
||||
import com.billpaymentservice.bbps.dto.Detail;
|
||||
import com.billpaymentservice.bbps.dto.GroupDTO;
|
||||
@@ -28,22 +31,37 @@ import com.billpaymentservice.bbps.dto.MasterCategoryBillerResponse;
|
||||
import com.billpaymentservice.bbps.dto.PlanDTO;
|
||||
import com.billpaymentservice.bbps.dto.TicketDetailsDTO;
|
||||
import com.billpaymentservice.bbps.dto.TicketDispositionsDTO;
|
||||
import com.billpaymentservice.bbps.dto.request.BillFetchByBillIdRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.FetchBillRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.FetchBillValidatestRequest;
|
||||
import com.billpaymentservice.bbps.dto.response.AmountOptionsResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.BillDataResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.ClientReqIdResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.ComplaintHistoryStatusResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.FetchBillValidateResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.PlanResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.TicketCheckStatusResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.ViewAllComplaintsResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.ViewAllComplaintsTicketsResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.ViewComplainByIdResponse;
|
||||
import com.billpaymentservice.bbps.dto.sentRequest.BillPaymentForwardRequest;
|
||||
import com.billpaymentservice.bbps.dto.sentRequest.FetchBillForwardRequest;
|
||||
import com.billpaymentservice.bbps.dto.sentRequest.FetchBillValidatestForwardRequest;
|
||||
import com.billpaymentservice.bbps.entites.AdditionalInfoBill;
|
||||
import com.billpaymentservice.bbps.entites.AdditionalInfoBillValidate;
|
||||
import com.billpaymentservice.bbps.entites.AdditionalInfoPlans;
|
||||
import com.billpaymentservice.bbps.entites.AmountOptionByBillerId;
|
||||
import com.billpaymentservice.bbps.entites.AmountOptionDetails;
|
||||
import com.billpaymentservice.bbps.entites.BillAdditionalInfo;
|
||||
import com.billpaymentservice.bbps.entites.BillCustomerParams;
|
||||
import com.billpaymentservice.bbps.entites.BillMaster;
|
||||
import com.billpaymentservice.bbps.entites.BillTag;
|
||||
import com.billpaymentservice.bbps.entites.BillValidation;
|
||||
import com.billpaymentservice.bbps.entites.BillerCategoryIcon;
|
||||
import com.billpaymentservice.bbps.entites.BillerCategoryWise;
|
||||
import com.billpaymentservice.bbps.entites.BillerDetails;
|
||||
import com.billpaymentservice.bbps.entites.BillerResponse;
|
||||
import com.billpaymentservice.bbps.entites.CategoryResponseList;
|
||||
import com.billpaymentservice.bbps.entites.CheckClientBillerData;
|
||||
import com.billpaymentservice.bbps.entites.CheckClientStatusReqId;
|
||||
@@ -51,6 +69,8 @@ import com.billpaymentservice.bbps.entites.ComplainStatus;
|
||||
import com.billpaymentservice.bbps.entites.ComplaintHistory;
|
||||
import com.billpaymentservice.bbps.entites.ComplaintStatusDetails;
|
||||
import com.billpaymentservice.bbps.entites.ContactMasterData;
|
||||
import com.billpaymentservice.bbps.entites.CustomerParamBill;
|
||||
import com.billpaymentservice.bbps.entites.CustomerParamBillValidation;
|
||||
import com.billpaymentservice.bbps.entites.CustomerParamGroupById;
|
||||
import com.billpaymentservice.bbps.entites.GroupParam;
|
||||
import com.billpaymentservice.bbps.entites.Plan;
|
||||
@@ -61,7 +81,11 @@ import com.billpaymentservice.bbps.entites.TicketDispositionDetails;
|
||||
import com.billpaymentservice.bbps.entites.ViewAllComplaintTicketStatusDetails;
|
||||
import com.billpaymentservice.bbps.exception.CustomException;
|
||||
import com.billpaymentservice.bbps.repository.AmountOptionByBillerIdRepository;
|
||||
import com.billpaymentservice.bbps.repository.BBPSMasterDataRepo;
|
||||
import com.billpaymentservice.bbps.repository.BillMasterRepository;
|
||||
import com.billpaymentservice.bbps.repository.BillValidationRepository;
|
||||
import com.billpaymentservice.bbps.repository.BillerCategoryWiseRepository;
|
||||
import com.billpaymentservice.bbps.repository.BillerDataRepository;
|
||||
import com.billpaymentservice.bbps.repository.CategoryResponseListRepository;
|
||||
import com.billpaymentservice.bbps.repository.CheckClientBillerDataRepository;
|
||||
import com.billpaymentservice.bbps.repository.ClientReqIdRepository;
|
||||
@@ -96,6 +120,10 @@ public class BillerMapperHelper {
|
||||
private final CheckClientBillerDataRepository checkClientBillerDataRepository;
|
||||
private final ViewAllComplainTicketDetailRepository viewAllComplainTicketDetailRepository;
|
||||
private final ContactMasterDataRepository contactMasterDataRepository;
|
||||
private final BBPSMasterDataRepo bbpsMasterDataRepo;
|
||||
private final BillerDataRepository billerDataRespository;
|
||||
private final BillMasterRepository billMasterRepository;
|
||||
private final BillValidationRepository billValidationRepository;
|
||||
|
||||
public BillerMapperHelper(BillerCategoryWiseRepository billerRepo,
|
||||
CustomerParamGroupByBillerIdRepository customerParamGroupByBillerIdRepo,
|
||||
@@ -109,7 +137,11 @@ public class BillerMapperHelper {
|
||||
CheckClientBillerDataRepository checkClientBillerDataRepository,
|
||||
TicketDispositionRepository ticketDispositionRepository,
|
||||
ViewAllComplainTicketDetailRepository viewAllComplainTicketDetailRepository,
|
||||
ContactMasterDataRepository contactMasterDataRepository) {
|
||||
ContactMasterDataRepository contactMasterDataRepository,
|
||||
BBPSMasterDataRepo bbpsMasterDataRepo,
|
||||
BillerDataRepository billerDataRespository,
|
||||
BillMasterRepository billMasterRepository,
|
||||
BillValidationRepository billValidationRepository) {
|
||||
this.billerRepo = billerRepo;
|
||||
this.customerParamGroupByBillerIdRepo = customerParamGroupByBillerIdRepo;
|
||||
this.amountOptionByBillerIdRepository = amountOptionByBillerIdRepository;
|
||||
@@ -125,6 +157,10 @@ public class BillerMapperHelper {
|
||||
this.ticketDispositionRepository = ticketDispositionRepository;
|
||||
this.viewAllComplainTicketDetailRepository = viewAllComplainTicketDetailRepository;
|
||||
this.contactMasterDataRepository = contactMasterDataRepository;
|
||||
this.bbpsMasterDataRepo = bbpsMasterDataRepo;
|
||||
this.billerDataRespository = billerDataRespository;
|
||||
this.billMasterRepository = billMasterRepository;
|
||||
this.billValidationRepository = billValidationRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -822,4 +858,198 @@ public class BillerMapperHelper {
|
||||
return "Contact Master Saved Successfully";
|
||||
}
|
||||
|
||||
public void saveOrUpdateBillerData(BillerDetails newEntity) {
|
||||
|
||||
Optional<BillerDetails> existingOpt = billerDataRespository.findByBillerId(newEntity.getBillerId());
|
||||
|
||||
if (existingOpt.isPresent()) {
|
||||
//logic to be written
|
||||
}
|
||||
else {
|
||||
// brand new biller
|
||||
billerDataRespository.save(newEntity);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveOrUpdateBillData(BillDataResponse responseWrapper,
|
||||
BillFetchByBillIdRequest billFetchByBillIdRequest,String txnId) {
|
||||
|
||||
|
||||
BillMaster billMaster = new BillMaster();
|
||||
|
||||
billMaster.setBillId(responseWrapper.getBillId());
|
||||
billMaster.setRefId(responseWrapper.getRefId());
|
||||
billMaster.setBillerId(responseWrapper.getBillerId());
|
||||
billMaster.setStatus(responseWrapper.getStatus());
|
||||
billMaster.setActionType(responseWrapper.getActionType());
|
||||
billMaster.setUserId(responseWrapper.getUserId());
|
||||
billMaster.setReqId(billFetchByBillIdRequest.getReqId());
|
||||
billMaster.setTxnId(txnId);
|
||||
|
||||
// BILLER RESPONSE
|
||||
BillerResponse billerResponse = new BillerResponse();
|
||||
if (responseWrapper.getBillerResponse() != null) {
|
||||
billerResponse.setBillId(responseWrapper.getBillerResponse().getBillId());
|
||||
billerResponse.setAmount(responseWrapper.getBillerResponse().getAmount());
|
||||
billerResponse.setBillDate(responseWrapper.getBillerResponse().getBillDate());
|
||||
billerResponse.setBillNumber(responseWrapper.getBillerResponse().getBillNumber());
|
||||
billerResponse.setBillPeriod(responseWrapper.getBillerResponse().getBillPeriod());
|
||||
billerResponse.setCustConvFee(responseWrapper.getBillerResponse().getCustConvFee());
|
||||
billerResponse.setCouCustConvFee(responseWrapper.getBillerResponse().getCouCustConvFee());
|
||||
billerResponse.setDueDate(responseWrapper.getBillerResponse().getDueDate());
|
||||
billerResponse.setCustomerName(responseWrapper.getBillerResponse().getCustomerName());
|
||||
billerResponse.setAmountOption(responseWrapper.getBillerResponse().isAmountOption());
|
||||
billerResponse.setBillMaster(billMaster);
|
||||
}
|
||||
billMaster.setBillerResponse(billerResponse);
|
||||
|
||||
|
||||
|
||||
// ADDITIONAL INFO
|
||||
List<AdditionalInfoBill> additionalInfos = new ArrayList<>();
|
||||
if (responseWrapper.getAdditionalInfo() != null) {
|
||||
for (AdditionalInfoBillDTO info : responseWrapper.getAdditionalInfo()) {
|
||||
AdditionalInfoBill entity = new AdditionalInfoBill();
|
||||
entity.setName(info.getName());
|
||||
entity.setValue(info.getValue());
|
||||
entity.setBillMaster(billMaster);
|
||||
additionalInfos.add(entity);
|
||||
}
|
||||
}
|
||||
billMaster.setAdditionalInfo(additionalInfos);
|
||||
|
||||
|
||||
|
||||
// CUSTOMER PARAMS
|
||||
List<CustomerParamBill> customerParams = new ArrayList<>();
|
||||
if (responseWrapper.getCustomerParams() != null) {
|
||||
for (CustomerParamDAO param : responseWrapper.getCustomerParams()) {
|
||||
CustomerParamBill entity = new CustomerParamBill();
|
||||
entity.setName(param.getName());
|
||||
entity.setValue(param.getValue() == null ? "" : param.getValue());
|
||||
entity.setType(param.getType() == null ? "" : param.getType());
|
||||
entity.setBillMaster(billMaster);
|
||||
customerParams.add(entity);
|
||||
}
|
||||
}
|
||||
billMaster.setCustomerParams(customerParams);
|
||||
|
||||
|
||||
|
||||
// DATES
|
||||
billMaster.setCreationDate(responseWrapper.getCreationDate());
|
||||
billMaster.setModifiedDate(responseWrapper.getModifiedDate());
|
||||
billMaster.setCreatedEpochDate(responseWrapper.getCreatedEpochDate());
|
||||
billMaster.setModifiedEpochDate(responseWrapper.getModifiedEpochDate());
|
||||
|
||||
|
||||
billMasterRepository.save(billMaster);
|
||||
}
|
||||
|
||||
public void saveBillValidation(FetchBillValidateResponse responseWrapper, BillFetchByBillIdRequest billRequest) {
|
||||
System.out.println("responseWrapper");
|
||||
ModelMapper modelMapper = new ModelMapper();
|
||||
|
||||
try {
|
||||
LOGGER.info("Saving bill validation data for billId={}", responseWrapper.getBillId());
|
||||
|
||||
// ✅ Map the main object
|
||||
BillValidation billEntity = modelMapper.map(responseWrapper, BillValidation.class);
|
||||
// ✅ Manually handle only the nested relationship part
|
||||
if (responseWrapper.getCustomerParams() != null) {
|
||||
List<CustomerParamBillValidation> customerParams = responseWrapper.getCustomerParams()
|
||||
.stream()
|
||||
.map(param -> {
|
||||
CustomerParamBillValidation cp = modelMapper.map(param, CustomerParamBillValidation.class);
|
||||
cp.setBill(billEntity); // maintain relation
|
||||
return cp;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
billEntity.setCustomerParams(customerParams);
|
||||
}
|
||||
if (responseWrapper.getAdditionalInfo() != null) {
|
||||
List<AdditionalInfoBillValidate> additionalInfos = responseWrapper.getAdditionalInfo()
|
||||
.stream()
|
||||
.map(info -> {
|
||||
AdditionalInfoBillValidate ai = modelMapper.map(info, AdditionalInfoBillValidate.class);
|
||||
ai.setBill(billEntity); // maintain relation
|
||||
return ai;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
billEntity.setAdditionalInfo(additionalInfos);
|
||||
|
||||
}
|
||||
// ✅ Save everything (cascade handles child)
|
||||
|
||||
billValidationRepository.save(billEntity);
|
||||
|
||||
LOGGER.info("Bill validation saved successfully for billId={}", billEntity.getBillId());
|
||||
} catch (Exception ex) {
|
||||
LOGGER.error("Error saving BillValidation data: {}", ex.getMessage(), ex);
|
||||
throw new RuntimeException("Failed to save bill validation data", ex);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public FetchBillForwardRequest fetchBillForwardRequestMap(FetchBillRequest req) {
|
||||
|
||||
FetchBillForwardRequest forward = new FetchBillForwardRequest();
|
||||
|
||||
forward.setBillerId(req.getBillerId());
|
||||
forward.setBillerName(req.getBillerName());
|
||||
forward.setBillerCategory(req.getBillerCategory());
|
||||
forward.setClientReqId(req.getClientReqId());
|
||||
forward.setMacAdress(req.getMacAdress());
|
||||
forward.setCustomerMobNo(req.getCustomerMobNo());
|
||||
forward.setRemitterName(req.getRemitterName());
|
||||
forward.setPaymentChannel(req.getPaymentChannel());
|
||||
forward.setDeviceBlockTags(req.getDeviceBlockTags());
|
||||
forward.setCustomerParamsRequest(req.getCustomerParamsRequest());
|
||||
forward.setRemitterIdentity(req.getRemitterIdentity());
|
||||
|
||||
return forward;
|
||||
}
|
||||
|
||||
public FetchBillValidatestForwardRequest fetchBillValidatestForwardRequest(FetchBillValidatestRequest req) {
|
||||
|
||||
FetchBillValidatestForwardRequest forward = new FetchBillValidatestForwardRequest();
|
||||
|
||||
forward.setBillerId(req.getBillerId());
|
||||
forward.setBillerName(req.getBillerName());
|
||||
forward.setBillerCategory(req.getBillerCategory());
|
||||
forward.setCustomerMobNo(req.getCustomerMobNo());
|
||||
forward.setClientReqId(req.getClientReqId());
|
||||
forward.setMacAddress(req.getMacAddress());
|
||||
forward.setCustomerParamsRequest(req.getCustomerParamsRequest());
|
||||
|
||||
return forward;
|
||||
}
|
||||
public BillPaymentForwardRequest billPaymentForwardRequest(BillPaymentRequest req) {
|
||||
|
||||
BillPaymentForwardRequest forward = new BillPaymentForwardRequest();
|
||||
|
||||
forward.setTenantId(req.getTenantId());
|
||||
forward.setRefId(req.getRefId());
|
||||
forward.setBillId(req.getBillId());
|
||||
forward.setAmountOptions(req.isAmountOptions());
|
||||
forward.setPaymentMode(req.getPaymentMode());
|
||||
forward.setPaymentInformation(req.getPaymentInformation());
|
||||
forward.setBillerId(req.getBillerId());
|
||||
forward.setBillerName(req.getBillerName());
|
||||
forward.setBillerCategory(req.getBillerCategory());
|
||||
forward.setMacAdress(req.getMacAdress());
|
||||
forward.setCustomerMobNo(req.getCustomerMobNo());
|
||||
forward.setTxnAmount(req.getTxnAmount());
|
||||
forward.setPaymentRefId(req.getPaymentRefId());
|
||||
forward.setClientReqId(req.getClientReqId());
|
||||
forward.setPaymentChannel(req.getPaymentChannel());
|
||||
|
||||
forward.setDeviceBlockTags(req.getDeviceBlockTags());
|
||||
forward.setCustomerParamsRequest(req.getCustomerParamsRequest());
|
||||
forward.setRemitterIdentity(req.getRemitterIdentity());
|
||||
forward.setAmountBreakSet(req.getAmountBreakSet());
|
||||
|
||||
return forward;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
package com.billpaymentservice.bbps.util;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.request.FetchBillRequest;
|
||||
import com.billpaymentservice.bbps.dto.sentRequest.FetchBillForwardRequest;
|
||||
import com.billpaymentservice.bbps.entites.BillerDetails;
|
||||
import com.billpaymentservice.bbps.entites.BillerResponseParams;
|
||||
import com.billpaymentservice.bbps.entites.InterchangeFee;
|
||||
|
||||
@@ -2,16 +2,12 @@ package com.billpaymentservice.bbps.util;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Component;
|
||||
<<<<<<< HEAD
|
||||
|
||||
import com.billpaymentservice.bbps.dto.AdditionalInfoBillDTO;
|
||||
import com.billpaymentservice.bbps.dto.CustomerParamDAO;
|
||||
@@ -31,17 +27,12 @@ import com.billpaymentservice.bbps.dto.sentRequest.FetchComplaintForwardRequest;
|
||||
import com.billpaymentservice.bbps.dto.sentRequest.FetchTicketLatestStatusRequest;
|
||||
import com.billpaymentservice.bbps.entites.AdditionalInfoBill;
|
||||
import com.billpaymentservice.bbps.entites.AdditionalInfoBillValidate;
|
||||
=======
|
||||
>>>>>>> d0812656ff2aee80b1eb0c0ab8e29a01d7d66553
|
||||
import com.billpaymentservice.bbps.entites.BBPSMastersData;
|
||||
import com.billpaymentservice.bbps.entites.BillMaster;
|
||||
import com.billpaymentservice.bbps.entites.BillValidation;
|
||||
import com.billpaymentservice.bbps.entites.BillerDetails;
|
||||
import com.billpaymentservice.bbps.entites.BillerResponse;
|
||||
import com.billpaymentservice.bbps.entites.CustomerParamBill;
|
||||
import com.billpaymentservice.bbps.entites.CustomerParamBillValidation;
|
||||
import com.billpaymentservice.bbps.entites.InboundTraceLog;
|
||||
import com.billpaymentservice.bbps.entites.OutboundTraceLog;
|
||||
import com.billpaymentservice.bbps.entites.PaymentChannel;
|
||||
import com.billpaymentservice.bbps.entites.PaymentMode;
|
||||
import com.billpaymentservice.bbps.entites.BharatConnectMaster;
|
||||
import com.billpaymentservice.bbps.exception.CustomException;
|
||||
import com.billpaymentservice.bbps.repository.BBPSMasterDataRepo;
|
||||
import com.billpaymentservice.bbps.repository.BillMasterRepository;
|
||||
@@ -61,14 +52,12 @@ public class Helper {
|
||||
private static final String CHARACTERS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
private static final SecureRandom secureRandom = new SecureRandom();
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
private final BBPSMasterDataRepo bbpsMasterDataRepo;
|
||||
private final BillerDataRepository billerDataRespository;
|
||||
private final BillMasterRepository billMasterRepository;
|
||||
private final BillValidationRepository billValidationRepository;
|
||||
|
||||
|
||||
// Constructor Injection
|
||||
public Helper(BBPSMasterDataRepo bbpsMasterDataRepo, InboundTraceLogRepository inboundTraceLogRepository,
|
||||
<<<<<<< HEAD
|
||||
OutboundTraceLogRepository outboundTraceLogRepository, BillerDataRepository billerDataRepository,
|
||||
BillMasterRepository billMasterRepository, BillValidationRepository billValidationRepository) {
|
||||
this.bbpsMasterDataRepo = bbpsMasterDataRepo;
|
||||
@@ -78,6 +67,13 @@ public class Helper {
|
||||
this.billMasterRepository = billMasterRepository;
|
||||
this.billValidationRepository = billValidationRepository;
|
||||
}
|
||||
=======
|
||||
OutboundTraceLogRepository outboundTraceLogRepository,BillerDataRepository billerDataRepository,
|
||||
BillMasterRepository billMasterRepository,BillValidationRepository billValidationRepository) {
|
||||
this.inboundTraceLogRepository = inboundTraceLogRepository;
|
||||
this.outboundTraceLogRepository = outboundTraceLogRepository;
|
||||
this.bbpsMasterDataRepo = bbpsMasterDataRepo;}
|
||||
>>>>>>> d0812656ff2aee80b1eb0c0ab8e29a01d7d66553
|
||||
|
||||
/**
|
||||
* Validates whether the merchant exists and is active.
|
||||
@@ -89,35 +85,6 @@ public class Helper {
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public <T> void startPolling(T requestObject, // Request object (any type)
|
||||
Function<T, ResponseModel> apiCallFunction, // Function to call API
|
||||
int intervalSeconds, // gap between two polls
|
||||
int maxDurationSeconds // total polling time
|
||||
) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
int maxAttempts = maxDurationSeconds / intervalSeconds;
|
||||
|
||||
for (int i = 0; i < maxAttempts; i++) {
|
||||
LOGGER.info("⏳ Polling attempt {}...", i + 1);
|
||||
|
||||
ResponseModel response = apiCallFunction.apply(requestObject);
|
||||
LOGGER.info("📥 Poll response: {}", response);
|
||||
|
||||
if ("SUCCESS".equalsIgnoreCase(response.getStatus())) {
|
||||
LOGGER.info("✅ Polling successful, stopping early.");
|
||||
break;
|
||||
}
|
||||
|
||||
Thread.sleep(intervalSeconds * 1000L);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("❌ Error in polling thread: {}", e.getMessage(), e);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void validateMerchant(String mid) {
|
||||
if (mid == null || mid == "") {
|
||||
LOGGER.warn("MerchantRequestModel or MID is null");
|
||||
@@ -215,12 +182,15 @@ public class Helper {
|
||||
outboundLog.setResponsePayload(responsePayload);
|
||||
outboundLog.setResponseReceiveTime(LocalDateTime.now());
|
||||
outboundTraceLogRepository.save(outboundLog);
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
>>>>>>> d0812656ff2aee80b1eb0c0ab8e29a01d7d66553
|
||||
}
|
||||
|
||||
/* ---------- End helpers ---------- */
|
||||
public void saveOrUpdateBillerData(BillerDetails newEntity) {
|
||||
|
||||
<<<<<<< HEAD
|
||||
Optional<BillerDetails> existingOpt = billerDataRespository.findByBillerId(newEntity.getBillerId());
|
||||
|
||||
if (existingOpt.isPresent()) {
|
||||
@@ -419,4 +389,18 @@ public class Helper {
|
||||
forward.setTxnNpciId(request.getTxnNpciId());
|
||||
return forward;
|
||||
}
|
||||
=======
|
||||
// New reusable header builder for BBPS calls
|
||||
public HttpHeaders buildHeaders(BharatConnectMaster headersData) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
if (headersData != null) {
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
}
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
return headers;
|
||||
}
|
||||
|
||||
>>>>>>> d0812656ff2aee80b1eb0c0ab8e29a01d7d66553
|
||||
}
|
||||
Reference in New Issue
Block a user