merged with himanshu code after bbps contant added

This commit is contained in:
Mohd-Arham
2025-11-25 11:46:47 +05:30
12 changed files with 1215 additions and 1045 deletions
@@ -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
}