Merge pull request 'feature3' (#7) from feature3 into develop

Reviewed-on: https://git.zeptic.in/himanshu/bbps/pulls/7
This commit is contained in:
Mohd_Arham
2025-11-04 11:09:39 +05:30
18 changed files with 607 additions and 238 deletions
@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.PostMapping;
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.ResponseModel;
import com.billpaymentservice.bbps.dto.request.BillerDetailRequest;
import com.billpaymentservice.bbps.dto.request.ContactMasterRequest;
@@ -16,6 +17,7 @@ import com.billpaymentservice.bbps.dto.request.CustomParamRequest;
import com.billpaymentservice.bbps.dto.request.DispositionRequest;
import com.billpaymentservice.bbps.dto.request.MasterCategoryRequest;
import com.billpaymentservice.bbps.dto.request.MasterRequest;
import com.billpaymentservice.bbps.dto.request.PlanRequest;
import com.billpaymentservice.bbps.service.MasterDataService;
import jakarta.validation.Valid;
@@ -108,7 +110,7 @@ public class MasterDataController {
* POST Fetch All AMount Options By Biller Id API Fetch Category Wise from BBPS
* URL
**/
@PostMapping(value = "/fetchPlanCategories", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@PostMapping(value = "/fetchAllPlanCategories", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseModel> fetchPlanCategories(@Validated @RequestBody BillerDetailRequest requestModel) {
return ResponseEntity.ok(masterDataService.fetchPlanCategorie(requestModel));
}
@@ -120,4 +122,15 @@ public class MasterDataController {
public ResponseEntity<ResponseModel> initiatingChannel(@Validated @RequestBody BillerDetailRequest requestModel) {
return ResponseEntity.ok(masterDataService.fetchInitiatingChannel(requestModel));
}
/**
* POST Fetch All AMount Options By Biller Id API Fetch Category Wise from BBPS
* URL
**/
@PostMapping(value = "/fetchPlanByCategoryName", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseModel> fetchPlanByCategory(@Validated @RequestBody PlanRequest requestModel) {
return ResponseEntity.ok(masterDataService.fetchPlanByCategories(requestModel));
}
}
@@ -0,0 +1,20 @@
package com.billpaymentservice.bbps.dto;
import java.util.List;
import java.util.UUID;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class AdditionalInfo {
private UUID planAdditionalInfoId;
private List<PlanTag> tags;
}
@@ -0,0 +1,17 @@
package com.billpaymentservice.bbps.dto;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class BillerIconDTO {
private String icon_data; // Base64 or image data
private String icon_type;
}
@@ -21,5 +21,6 @@ public class MasterCategoryBillerResponse {
private String planMDMRequirement;
private String adhocBiller;
private String paymentAmountExactness;
private BillerIconDTO biller_icon;
}
@@ -0,0 +1,27 @@
package com.billpaymentservice.bbps.dto;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class PlanDTO {
private String planId;
private String description;
private String billerId;
private String categoryType;
private List<String> categorySubType; // comes as empty array []
private String amountInRupees; // numeric but mapped as String for safety
private String effctvFrom;
private String effctvTo;
private String status;
private AdditionalInfo additionalInfo;
}
@@ -0,0 +1,20 @@
package com.billpaymentservice.bbps.dto;
import java.util.UUID;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class PlanTag {
private UUID tagId;
private String name;
private String value;
}
@@ -0,0 +1,18 @@
package com.billpaymentservice.bbps.dto;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class PlansListDTO {
private List<PlanDTO> plans;
}
@@ -18,11 +18,11 @@ import lombok.ToString;
@ToString
public class FetchBillRequest extends BaseClass {
private String tenantId; // M
// private String tenantId; // M
private String billerId; // M
private String billerName; //M
private String digiledgeKey; // M
private String agentId; // M
// private String digiledgeKey; // M
// private String agentId; // M
private String billerCategory; // M
private String clientReqId; // C
private String macAdress; // C
@@ -0,0 +1,33 @@
package com.billpaymentservice.bbps.dto.request;
import jakarta.validation.constraints.NotBlank;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
/**
* DTO for fetching plan list from /masters/plans endpoint.
*/
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class PlanRequest extends BaseClass {
// ✅ Mandatory: 14-character alphanumeric
@NotBlank(message = "billerId is mandatory")
private String billerId;
// ✅ Conditional (optional)
private String category;
private String amountInRupees;
private String circle;
// ✅ Optional pagination parameters
private Integer page;
private Integer pagesize;
}
@@ -0,0 +1,27 @@
package com.billpaymentservice.bbps.dto.response;
import com.billpaymentservice.bbps.dto.GeneralResp;
import com.billpaymentservice.bbps.dto.PlansListDTO;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class PlanResponse {
private PlansListDTO plansList; // contains "plans"
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private GeneralResp generalResp; // status/message block
private int pageNo;
private int pageSize;
private long totalElements;
private int totalPages;
}
@@ -0,0 +1,46 @@
package com.billpaymentservice.bbps.entites;
import com.billpaymentservice.bbps.audit.Auditable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Entity
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Getter
@Setter
@Table(name = "bbps_master_data")
public class BBPSMastersData extends Auditable<String> {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private Long id;
@Column(name = "mid")
private String mid;
@Column(name = "api_key")
private String apiKey;
@Column(name = "secrete_key")
private String secreteKey;
@Column(name = "is_active")
private Boolean isActive;
@Column(name = "user_name")
private String userName;
}
@@ -0,0 +1,14 @@
package com.billpaymentservice.bbps.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import com.billpaymentservice.bbps.entites.BBPSMastersData;
@Repository
public interface BBPSMasterDataRepo extends JpaRepository<BBPSMastersData, Long> {
@Query("from BBPSMastersData where mid = ?1 and isDeleted = false")
public BBPSMastersData findByMid(String mid);
}
@@ -2,9 +2,11 @@ package com.billpaymentservice.bbps.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import com.billpaymentservice.bbps.entites.BBPSMerchantValidation;
@Repository
public interface MerchantRepository extends JpaRepository<BBPSMerchantValidation, Long> {
@Query("from BBPSMerchantValidation where mid = ?1 and is_deleted = false")
@@ -8,6 +8,8 @@ import com.billpaymentservice.bbps.dto.request.DispositionRequest;
import com.billpaymentservice.bbps.dto.request.MasterCategoryRequest;
import com.billpaymentservice.bbps.dto.request.MasterRequest;
import com.billpaymentservice.bbps.dto.request.MerchantRequestModel;
import com.billpaymentservice.bbps.dto.request.PlanRequest;
import jakarta.servlet.http.HttpServletRequest;
public interface MasterDataService {
@@ -32,4 +34,6 @@ public interface MasterDataService {
public ResponseModel getDispositionDetails(DispositionRequest dispositionDetailRequest);
public ResponseModel fetchPlanByCategories(PlanRequest requestModel);
}
@@ -51,6 +51,9 @@ public class AgentServiceImpl implements AgentService {
@Override
public ResponseModel initiateBillFetch(FetchBillRequest fetchBillRequest) {
helper.validateMerchant(fetchBillRequest.getMid());
String url = agentDtaUrl + BBPSConstant.BILL_FETCH_INTI;
System.out.println(url);
@@ -73,6 +76,7 @@ public class AgentServiceImpl implements AgentService {
// ✅ Call the API using httpService
Map<String, String> responseMap = httpService.postRequest(url, json, headers);
log.info("Response -: " + responseMap);
String responseData = responseMap.get("data");
log.info("📦 Bill Fetch API Response: {}", responseData);
@@ -108,6 +112,9 @@ public class AgentServiceImpl implements AgentService {
responseModel = new ResponseModel(generalResponse.getMessage(), generalResponse.getStatus(),
Integer.parseInt(generalResponse.getStatusCode()), fetchBillResponse);
} catch (CustomException ex) {
log.warn("Merchant validation failed: {}", ex.getMessage());
return ex.getResponseModel(); // Directly return ResponseModel from exception
} catch (Exception e) {
log.error("❌ Exception in initiateBillFetch(): {}", e.getMessage(), e);
responseModel.setStatus("500");
@@ -121,25 +128,28 @@ public class AgentServiceImpl implements AgentService {
@Override
public ResponseModel fetchBillById(BillFetchByBillIdRequest billFetchByBillIdRequest) {
String billId = billFetchByBillIdRequest.getBillId();
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + billId;
System.out.print(fullUrl);
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);
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
String responseData = responseMap.get("data");
log.info("data is :{}", responseData);
ObjectMapper objectMapper = new ObjectMapper();
try {
helper.validateMerchant(billFetchByBillIdRequest.getMid());
String billId = billFetchByBillIdRequest.getBillId();
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + billId;
System.out.print(fullUrl);
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);
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
String responseData = responseMap.get("data");
log.info("data is :{}", responseData);
ObjectMapper objectMapper = new ObjectMapper();
Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
});
@@ -162,6 +172,9 @@ public class AgentServiceImpl implements AgentService {
} catch (JsonProcessingException e) {
log.error("Error parsing responseData JSON: {}", e.getMessage());
throw new CustomException("Invalid JSON received from API");
} catch (CustomException ex) {
log.warn("Merchant validation failed: {}", ex.getMessage());
return ex.getResponseModel(); // Directly return ResponseModel from exception
}
}
@@ -171,6 +184,9 @@ public class AgentServiceImpl implements AgentService {
ResponseModel responseModel = new ResponseModel();
try {
helper.validateMerchant(fetchBillValidateRequest.getMid());
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
if (headersData == null) {
@@ -216,6 +232,9 @@ public class AgentServiceImpl implements AgentService {
responseModel = new ResponseModel(generalResponse.getMessage(), generalResponse.getStatus(),
Integer.parseInt(generalResponse.getStatusCode()), fetchBillResponse);
} catch (CustomException ex) {
log.warn("Merchant validation failed: {}", ex.getMessage());
return ex.getResponseModel(); // Directly return ResponseModel from exception
} catch (Exception e) {
log.error("❌ Exception in initiateBillFetch(): {}", e.getMessage(), e);
responseModel.setStatus("500");
@@ -231,6 +250,7 @@ public class AgentServiceImpl implements AgentService {
ResponseModel responseModel = new ResponseModel();
try {
helper.validateMerchant(billRequest.getMid());
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
@@ -281,6 +301,9 @@ public class AgentServiceImpl implements AgentService {
responseModel = new ResponseModel(generalResponse.getRemarks(), generalResponse.getStatus(),
Integer.parseInt(generalResponse.getStatusCode()), fetchBillResponse);
} catch (CustomException ex) {
log.warn("Merchant validation failed: {}", ex.getMessage());
return ex.getResponseModel(); // Directly return ResponseModel from exception
} catch (Exception e) {
log.error("❌ Exception in initiateBillFetch(): {}", e.getMessage(), e);
responseModel.setStatus("500");
@@ -20,6 +20,7 @@ import com.billpaymentservice.bbps.dto.request.CustomParamRequest;
import com.billpaymentservice.bbps.dto.request.DispositionRequest;
import com.billpaymentservice.bbps.dto.request.MasterCategoryRequest;
import com.billpaymentservice.bbps.dto.request.MasterRequest;
import com.billpaymentservice.bbps.dto.request.PlanRequest;
import com.billpaymentservice.bbps.dto.response.AmountOptionsResponse;
import com.billpaymentservice.bbps.dto.response.BillerDataResponse;
import com.billpaymentservice.bbps.dto.response.BillerResponse;
@@ -27,6 +28,7 @@ import com.billpaymentservice.bbps.dto.response.ChannelsListResponse;
import com.billpaymentservice.bbps.dto.response.CustomParamResp;
import com.billpaymentservice.bbps.dto.response.CustomerParamGroupsResponse;
import com.billpaymentservice.bbps.dto.response.DispositionResponse;
import com.billpaymentservice.bbps.dto.response.PlanResponse;
import com.billpaymentservice.bbps.dto.response.PlaneCategoriesResponse;
import com.billpaymentservice.bbps.entites.BharatConnectMaster;
import com.billpaymentservice.bbps.entites.BillerDetails;
@@ -67,7 +69,6 @@ public class MasterDataServiceImpl implements MasterDataService {
private final ObjectMapper objectMapper = new ObjectMapper();
private final InboundTraceLogRepository inboundTraceLogRepository;
private final OutboundTraceLogRepository outboundTraceLogRepository;
public MasterDataServiceImpl(MerchantRepository merchantRegisterRepo, HttpService httpService,
HttpClientApi httpClientApi, Helper helper, BillerDataRepository billerDataRespository,
@@ -83,45 +84,52 @@ public class MasterDataServiceImpl implements MasterDataService {
this.beneficiaryDetailsRepository = beneficiaryDetailsRepository;
this.inboundTraceLogRepository = inboundTraceLogRepository;
this.outboundTraceLogRepository = outboundTraceLogRepository;
}
/* ---------- Trace helper methods ---------- */
private InboundTraceLog createInboundLog(String requestId, String txnId, String apiName, String mid, String httpMethod, String requestPayload) {
InboundTraceLog inboundLog = new InboundTraceLog(requestId, txnId, apiName, mid == null ? "N/A" : mid, "BBPS_ORG", httpMethod, requestPayload == null ? "N/A" : requestPayload);
inboundTraceLogRepository.save(inboundLog);
return inboundLog;
private InboundTraceLog createInboundLog(String requestId, String txnId, String apiName, String mid,
String httpMethod, String requestPayload) {
InboundTraceLog inboundLog = new InboundTraceLog(requestId, txnId, apiName, mid == null ? "N/A" : mid,
"BBPS_ORG", httpMethod, requestPayload == null ? "N/A" : requestPayload);
inboundTraceLogRepository.save(inboundLog);
return inboundLog;
}
private void updateInboundLogSuccess(InboundTraceLog inboundLog, String responsePayload, String responseCode) {
if (inboundLog == null) return;
inboundLog.setResponsePayload(responsePayload);
inboundLog.setResponseCode(responseCode);
inboundLog.setStatus("SUCCESS");
inboundLog.setResponseTime(LocalDateTime.now());
inboundTraceLogRepository.save(inboundLog);
if (inboundLog == null)
return;
inboundLog.setResponsePayload(responsePayload);
inboundLog.setResponseCode(responseCode);
inboundLog.setStatus("SUCCESS");
inboundLog.setResponseTime(LocalDateTime.now());
inboundTraceLogRepository.save(inboundLog);
}
private void updateInboundLogFailure(InboundTraceLog inboundLog, String responsePayload, String responseCode) {
if (inboundLog == null) return;
inboundLog.setResponsePayload(responsePayload);
inboundLog.setResponseCode(responseCode);
inboundLog.setStatus("FAILED");
inboundLog.setResponseTime(LocalDateTime.now());
inboundTraceLogRepository.save(inboundLog);
if (inboundLog == null)
return;
inboundLog.setResponsePayload(responsePayload);
inboundLog.setResponseCode(responseCode);
inboundLog.setStatus("FAILED");
inboundLog.setResponseTime(LocalDateTime.now());
inboundTraceLogRepository.save(inboundLog);
}
private OutboundTraceLog createOutboundLog(String txnId, String requestId, String apiName, String url, String httpMethod, String requestPayload) {
OutboundTraceLog outboundLog = new OutboundTraceLog(txnId, requestId, apiName, url, httpMethod, requestPayload == null ? "N/A" : requestPayload);
outboundTraceLogRepository.save(outboundLog);
return outboundLog;
private OutboundTraceLog createOutboundLog(String txnId, String requestId, String apiName, String url,
String httpMethod, String requestPayload) {
OutboundTraceLog outboundLog = new OutboundTraceLog(txnId, requestId, apiName, url, httpMethod,
requestPayload == null ? "N/A" : requestPayload);
outboundTraceLogRepository.save(outboundLog);
return outboundLog;
}
private void updateOutboundLogResponse(OutboundTraceLog outboundLog, String responsePayload) {
if (outboundLog == null) return;
outboundLog.setResponsePayload(responsePayload);
outboundLog.setResponseReceiveTime(LocalDateTime.now());
outboundTraceLogRepository.save(outboundLog);
if (outboundLog == null)
return;
outboundLog.setResponsePayload(responsePayload);
outboundLog.setResponseReceiveTime(LocalDateTime.now());
outboundTraceLogRepository.save(outboundLog);
}
/* ---------- End helpers ---------- */
@@ -132,19 +140,30 @@ public class MasterDataServiceImpl implements MasterDataService {
String txnID = helper.generateTxnId(15);
String apiName = "GetMasterData";
String requestId =masterRequest.getReqId();
String requestId = masterRequest.getReqId();
String requestJson = helper.convertObjectToJson(masterRequest);
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName, masterRequest.getMid(), "POST", requestJson);
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName, masterRequest.getMid(), "POST",
requestJson);
try {
// Merchant Validation
helper.validateMerchant(masterRequest.getMid());
// if (!"Valid".equalsIgnoreCase(validateMerchant)) {
// LOGGER.warn("Merchant validation failed: {}", validateMerchant);
// return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
// }
// check Tender Id is present DB
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
log.info("ResPONSE" + headersData);
log.info("Response -: " + headersData);
if (headersData == null) {
updateInboundLogFailure(inboundLog, "Tenant Id Is Null", "NOT_FOUND");
return new ResponseModel("Tenant Id Is Null", "Not Found",
BBPSConstant.BADREQUEST, headersData);
return new ResponseModel("Tenant Id Is Null", "Not Found", BBPSConstant.BADREQUEST, headersData);
}
// get full url
String fullUrl = masterRegisterUrl + BBPSConstant.MASTER_CATEGORY_URL + headersData.getTenantId();
LOGGER.info("Calling external API: {}", fullUrl);
@@ -183,65 +202,66 @@ public class MasterDataServiceImpl implements MasterDataService {
log.error("Error parsing responseData JSON: {}", e.getMessage());
updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
throw new CustomException("Invalid JSON received from API");
} catch (CustomException ex) {
LOGGER.warn("Merchant validation failed: {}", ex.getMessage());
return ex.getResponseModel(); // Directly return ResponseModel from exception
}
}
@Override
public ResponseModel getBillerByBillerId(BillerDetailRequest billerDetailRequest) {
String txnID = helper.generateTxnId(15);
String apiName = "GetBillerByBillerId";
String requestId = billerDetailRequest.getReqId();
String billerId = billerDetailRequest.getBillerId();
String fullUrl = masterRegisterUrl + BBPSConstant.BILLER_DATA_FETCH_URL + billerId;
String requestJson = helper.convertObjectToJson(billerDetailRequest);
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName, billerDetailRequest.getMid(), "POST", requestJson);
OutboundTraceLog outboundLog = createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
helper.validateMerchant(billerDetailRequest.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "GetBillerByBillerId";
String requestId = billerDetailRequest.getReqId();
String billerId = billerDetailRequest.getBillerId();
String fullUrl = masterRegisterUrl + BBPSConstant.BILLER_DATA_FETCH_URL + billerId;
Map<String, String> responseMap = httpService.getRequest(fullUrl);
String responseData = responseMap.get("data");
log.info("data is :{}", responseData);
String requestJson = helper.convertObjectToJson(billerDetailRequest);
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName, billerDetailRequest.getMid(), "POST",
requestJson);
updateOutboundLogResponse(outboundLog, responseData);
OutboundTraceLog outboundLog = createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
try {
Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {});
if (!dataMap.containsKey("generalResp")) {
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"))
);
}
BillerDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillerDataResponse.class);
GeneralResp generalResp = responseWrapper.getGeneralResp();
ModelMapper mapper = new ModelMapper();
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
BillerDetails entity = mapper.map(responseWrapper.getBillerDAO(), BillerDetails.class);
EntityRelationshipUtil.linkBillerRelationships(entity);
ResponseModel responseModel = new ResponseModel(
generalResp.getMessage(),
generalResp.getStatus(),
Integer.parseInt(generalResp.getStatusCode()),
responseWrapper
);
Map<String, String> responseMap = httpService.getRequest(fullUrl);
String responseData = responseMap.get("data");
log.info("data is :{}", responseData);
updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
updateOutboundLogResponse(outboundLog, responseData);
try {
Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey("generalResp")) {
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")));
}
BillerDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillerDataResponse.class);
GeneralResp generalResp = responseWrapper.getGeneralResp();
ModelMapper mapper = new ModelMapper();
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
BillerDetails entity = mapper.map(responseWrapper.getBillerDAO(), BillerDetails.class);
EntityRelationshipUtil.linkBillerRelationships(entity);
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
return responseModel;
} catch (JsonProcessingException e) {
log.error("Error parsing responseData JSON: {}", e.getMessage());
updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
throw new CustomException("Invalid JSON received from API");
}
return responseModel;
} catch (JsonProcessingException e) {
log.error("Error parsing responseData JSON: {}", e.getMessage());
updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
throw new CustomException("Invalid JSON received from API");
}
}
@Override
@@ -251,9 +271,16 @@ public class MasterDataServiceImpl implements MasterDataService {
String apiName = "GetCustomerParamByBillerId";
String requestId = customerParamRequest.getReqId();
String requestJson = helper.convertObjectToJson(customerParamRequest);
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName,customerParamRequest.getMid(), "POST", requestJson);
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName, customerParamRequest.getMid(), "POST",
requestJson);
try {
helper.validateMerchant(customerParamRequest.getMid());
// if (!"Valid".equalsIgnoreCase(validateMerchant)) {
// LOGGER.warn("Merchant validation failed: {}", validateMerchant);
// return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
// }
String billerId = customerParamRequest.getBillerId();
String fullUrl = masterRegisterUrl + BBPSConstant.CUSTOMPARAM_URL + billerId;
@@ -290,23 +317,16 @@ public class MasterDataServiceImpl implements MasterDataService {
log.error("Error parsing responseData JSON: {}", e.getMessage());
updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
throw new CustomException("Invalid JSON received from API");
} catch (CustomException ex) {
LOGGER.warn("Merchant validation failed: {}", ex.getMessage());
return ex.getResponseModel(); // Directly return ResponseModel from exception
}
}
@Override
public ResponseModel getContactMaster(ContactMasterRequest contactMasterRequest) {
/*
* String txnID = helper.generateTxnId(15); String apiName = "GetContactMaster";
* String requestId = contactMasterRequest != null ?
* contactMasterRequest.getReqId() : "N/A"; String requestJson =
* helper.convertObjectToJson(contactMasterRequest); InboundTraceLog inboundLog
* = createInboundLog(requestId, txnID, apiName, contactMasterRequest != null ?
* contactMasterRequest.getMid() : "N/A", "POST", requestJson);
*
* // Implementation not present previously - create inbound log and return
* empty response updateInboundLogSuccess(inboundLog, "N/A", "SUCCESS");
*/
return new ResponseModel();
}
@@ -318,17 +338,11 @@ public class MasterDataServiceImpl implements MasterDataService {
String apiName = "FetchMasterDataCategoryWise";
String requestId = masterRequest.getReqId();
String requestJson = helper.convertObjectToJson(masterRequest);
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName,masterRequest.getMid(), "POST", requestJson);
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName, masterRequest.getMid(), "POST",
requestJson);
try {
String validateMerchant = helper.validateMerchant(masterRequest);
if (!"Valid".equalsIgnoreCase(validateMerchant)) {
LOGGER.warn("Merchant validation failed: {}", validateMerchant);
updateInboundLogFailure(inboundLog, validateMerchant, "INVALID_MERCHANT");
return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
}
helper.validateMerchant(masterRequest.getMid());
String fullUrl = String.format("%s%s?billerName=%s&category=%s&page=%d&pagesize=%d", masterRegisterUrl,
BBPSConstant.BILLER_URL, masterRequest.getBillerName(), masterRequest.getCategory(),
@@ -368,6 +382,9 @@ public class MasterDataServiceImpl implements MasterDataService {
log.error("Error parsing responseData JSON: {}", e.getMessage());
updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
throw new CustomException("Invalid JSON received from API");
} catch (CustomException ex) {
LOGGER.warn("Merchant validation failed: {}", ex.getMessage());
return ex.getResponseModel(); // Directly return ResponseModel from exception
}
}
@@ -375,8 +392,10 @@ public class MasterDataServiceImpl implements MasterDataService {
public ResponseModel getDispositionDetails(DispositionRequest dispositionDetailRequest) {
String txnID = helper.generateTxnId(15);
String apiName = "GetDispositionDetails";
String requestId = dispositionDetailRequest.getReqId();;
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName,dispositionDetailRequest.getMid() , "GET", "N/A");
String requestId = dispositionDetailRequest.getReqId();
;
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName, dispositionDetailRequest.getMid(),
"GET", "N/A");
String fullUrl = masterRegisterUrl + BBPSConstant.DISPOSTION_URL;
OutboundTraceLog outboundLog = createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
@@ -384,8 +403,10 @@ public class MasterDataServiceImpl implements MasterDataService {
String responseData = responseMap.get("data");
updateOutboundLogResponse(outboundLog, responseData);
try {
ObjectMapper objectMapper = new ObjectMapper();
Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
});
@@ -423,6 +444,9 @@ public class MasterDataServiceImpl implements MasterDataService {
log.error("Error parsing responseData JSON: {}", e.getMessage());
updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
throw new CustomException("Invalid JSON received from API");
} catch (CustomException ex) {
LOGGER.warn("Merchant validation failed: {}", ex.getMessage());
return ex.getResponseModel(); // Directly return ResponseModel from exception
}
}
@@ -433,17 +457,11 @@ public class MasterDataServiceImpl implements MasterDataService {
String txnID = helper.generateTxnId(15);
String apiName = "FetchCustomerParamGroup";
String requestId = requestModel.getReqId();
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName,requestModel.getMid() , "POST", helper.convertObjectToJson(requestModel));
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "POST",
helper.convertObjectToJson(requestModel));
try {
String validateMerchant = helper.validateMerchant(requestModel);
if (!"Valid".equalsIgnoreCase(validateMerchant)) {
LOGGER.warn("Merchant validation failed: {}", validateMerchant);
updateInboundLogFailure(inboundLog, validateMerchant, "INVALID_MERCHANT");
return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
}
helper.validateMerchant(requestModel.getMid());
String fullUrl = masterRegisterUrl + BBPSConstant.CUSTOMER_PARAM_GROUP + requestModel.getBillerId();
OutboundTraceLog outboundLog = createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
@@ -479,6 +497,9 @@ public class MasterDataServiceImpl implements MasterDataService {
log.error("Error parsing responseData JSON: {}", e.getMessage());
updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
throw new CustomException("Invalid JSON received from API");
} catch (CustomException ex) {
LOGGER.warn("Merchant validation failed: {}", ex.getMessage());
return ex.getResponseModel(); // Directly return ResponseModel from exception
}
}
@@ -489,17 +510,12 @@ public class MasterDataServiceImpl implements MasterDataService {
String txnID = helper.generateTxnId(15);
String apiName = "FetchAllMasterAmountOption";
String requestId = requestModel.getReqId();
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "POST", helper.convertObjectToJson(requestModel));
String requestId = requestModel.getReqId();
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "POST",
helper.convertObjectToJson(requestModel));
try {
String validateMerchant = helper.validateMerchant(requestModel);
if (!"Valid".equalsIgnoreCase(validateMerchant)) {
LOGGER.warn("Merchant validation failed: {}", validateMerchant);
updateInboundLogFailure(inboundLog, validateMerchant, "INVALID_MERCHANT");
return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
}
helper.validateMerchant(requestModel.getMid());
String fullUrl = masterRegisterUrl + BBPSConstant.AMOUNT_OPTIONS + requestModel.getBillerId();
OutboundTraceLog outboundLog = createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
@@ -540,6 +556,7 @@ public class MasterDataServiceImpl implements MasterDataService {
LOGGER.error("Custom Exception: {}", e.getMessage());
throw e; // Rethrow custom exceptions to be handled by the controller
}
}
@Override
@@ -548,17 +565,12 @@ public class MasterDataServiceImpl implements MasterDataService {
String txnID = helper.generateTxnId(15);
String apiName = "FetchPlanCategorie";
String requestId = requestModel.getReqId();
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName, requestModel.getMid() , "POST", helper.convertObjectToJson(requestModel));
String requestId = requestModel.getReqId();
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "POST",
helper.convertObjectToJson(requestModel));
try {
String validateMerchant = helper.validateMerchant(requestModel);
if (!"Valid".equalsIgnoreCase(validateMerchant)) {
LOGGER.warn("Merchant validation failed: {}", validateMerchant);
updateInboundLogFailure(inboundLog, validateMerchant, "INVALID_MERCHANT");
return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
}
helper.validateMerchant(requestModel.getMid());
String fullUrl = masterRegisterUrl + BBPSConstant.PLAN_CATEGORIES + requestModel.getBillerId();
OutboundTraceLog outboundLog = createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
@@ -607,17 +619,12 @@ public class MasterDataServiceImpl implements MasterDataService {
String txnID = helper.generateTxnId(15);
String apiName = "FetchInitiatingChannel";
String requestId =requestModel.getReqId();
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "POST", helper.convertObjectToJson(requestModel));
String requestId = requestModel.getReqId();
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "POST",
helper.convertObjectToJson(requestModel));
try {
String validateMerchant = helper.validateMerchant(requestModel);
if (!"Valid".equalsIgnoreCase(validateMerchant)) {
LOGGER.warn("Merchant validation failed: {}", validateMerchant);
updateInboundLogFailure(inboundLog, validateMerchant, "INVALID_MERCHANT");
return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
}
helper.validateMerchant(requestModel.getMid());
String fullUrl = masterRegisterUrl + BBPSConstant.INITIATING_CHANNEL;
LOGGER.info("Calling Master API: {}", fullUrl);
@@ -662,4 +669,58 @@ public class MasterDataServiceImpl implements MasterDataService {
}
}
@Override
public ResponseModel fetchPlanByCategories(PlanRequest requestModel) {
LOGGER.info("Fetching Initiating Fetch Plan Category By Bidder Id for MID={}", requestModel.getMid());
try {
helper.validateMerchant(requestModel.getMid());
// if (!"Valid".equalsIgnoreCase(validateMerchant)) {
// LOGGER.warn("Merchant validation failed: {}", validateMerchant);
// return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
// }
String url = String.format("%s%s?billerId=%s%s%s%s&page=%d&pagesize=%d", masterRegisterUrl,
BBPSConstant.PLANS_URL, requestModel.getBillerId(),
requestModel.getCategory() != null ? "&category=" + requestModel.getCategory() : "",
requestModel.getAmountInRupees() != null ? "&amountInRupees=" + requestModel.getAmountInRupees()
: "",
requestModel.getCircle() != null ? "&circle=" + requestModel.getCircle() : "",
requestModel.getPage(), requestModel.getPagesize());
// String fullUrl = masterRegisterUrl + BBPSConstant.PLANS_URL + url;
LOGGER.info("Calling Master API: {}", url);
Map<String, String> apiResponse = httpService.getRequest(url);
log.info("Response" + apiResponse);
String responseData = apiResponse.get("data").toString();
Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey("generalResp")) {
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")));
}
PlanResponse responseWrapper = objectMapper.convertValue(dataMap, PlanResponse.class);
GeneralResp generalResp = responseWrapper.getGeneralResp();
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
return responseModel;
} catch (JsonProcessingException e) {
log.error("Error parsing responseData JSON: {}", e.getMessage());
throw new CustomException("Invalid JSON received from API");
} catch (CustomException e) {
LOGGER.error("Custom Exception: {}", e.getMessage());
throw e; // Rethrow custom exceptions to be handled by the controller
}
}
}
@@ -42,5 +42,7 @@ public class BBPSConstant {
public static final String PAYMENT_URL = "/agent/bills/payment";
public static final String CHECK_TRANSACTION_URL = "/transactions/payment/byTxnId?txnId=";
public static final String DISPOSTION_URL = "/disposition";
public static final String PLANS_URL = "/plans";
}
@@ -5,10 +5,12 @@ import java.util.function.Function;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.billpaymentservice.bbps.dto.ResponseModel;
import com.billpaymentservice.bbps.entites.BBPSMastersData;
import com.billpaymentservice.bbps.exception.CustomException;
import com.billpaymentservice.bbps.repository.BBPSMasterDataRepo;
import com.billpaymentservice.bbps.dto.request.BillerDetailRequest;
import com.billpaymentservice.bbps.dto.request.MerchantRequestModel;
import com.billpaymentservice.bbps.entites.BBPSMerchantValidation;
@@ -17,20 +19,21 @@ import com.billpaymentservice.bbps.repository.MerchantRepository;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@Component
public class Helper {
private static final Logger LOGGER = LoggerFactory.getLogger(Helper.class);
private static final String CHARACTERS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
private static final SecureRandom secureRandom = new SecureRandom();
private final ObjectMapper objectMapper = new ObjectMapper();
private final ObjectMapper objectMapper = new ObjectMapper();
private final BBPSMasterDataRepo bbpsMasterDataRepo;
@Autowired
private MerchantRepository merchantRegisterRepo;
// Constructor Injection
public Helper(BBPSMasterDataRepo bbpsMasterDataRepo) {
this.bbpsMasterDataRepo = bbpsMasterDataRepo;
}
/**
* Validates whether the merchant exists and is active.
@@ -42,85 +45,121 @@ 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
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;
new Thread(() -> {
try {
int maxAttempts = maxDurationSeconds / intervalSeconds;
for (int i = 0; i < maxAttempts; i++) {
LOGGER.info("⏳ Polling attempt {}...", i + 1);
for (int i = 0; i < maxAttempts; i++) {
LOGGER.info("⏳ Polling attempt {}...", i + 1);
ResponseModel response = apiCallFunction.apply(requestObject);
LOGGER.info("📥 Poll response: {}", response);
ResponseModel response = apiCallFunction.apply(requestObject);
LOGGER.info("📥 Poll response: {}", response);
if ("SUCCESS".equalsIgnoreCase(response.getStatus())) {
LOGGER.info("✅ Polling successful, stopping early.");
break;
}
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();
Thread.sleep(intervalSeconds * 1000L);
}
} catch (Exception e) {
LOGGER.error("❌ Error in polling thread: {}", e.getMessage(), e);
}
}).start();
}
public boolean isMerchantValidAndActive(MerchantRequestModel requestModel) {
if (requestModel == null || requestModel.getMid() == null) {
// public boolean isMerchantValidAndActive(MerchantRequestModel requestModel) {
//
// if (requestModel == null) {
// LOGGER.warn("MerchantRequestModel or MID is null");
// throw new CustomException("Invalid request: MID is required");
// }
//
// // Fetch merchant details
// BBPSMastersData merchantValidation = bbpsMasterDataRepo.findByMid(requestModel.getMid());
//
// if (merchantValidation == null) {
// LOGGER.warn("Merchant not found for MID: {}", requestModel.getMid());
// throw new CustomException("Merchant not found");
// }
//
// if (merchantValidation.getApiKey() == null && merchantValidation.getSecreteKey() == null) {
//
// throw new CustomException("Merchant inactive");
// }
//
// if (!Boolean.TRUE.equals(merchantValidation.getIsActive())) {
// LOGGER.warn("Merchant inactive for MID: {}", requestModel.getMid());
// throw new CustomException("Merchant inactive");
// }
//
// LOGGER.info("Merchant is valid and active for MID: {}", requestModel.getMid());
// return true;
// }
// public String validateMerchant(String mid) {
//
// if (mid == null) {
// LOGGER.warn("MerchantRequestModel or MID is null");
// return "Mid is required";
// }
//
// // Fetch merchant details
// BBPSMastersData merchantValidation = bbpsMasterDataRepo.findByMid(mid);
//
// if (merchantValidation == null) {
// LOGGER.warn("Merchant not found for MID: {}", mid);
// return "Merchant not found by id";
// }
//
// if (merchantValidation.getApiKey() == null && merchantValidation.getSecreteKey() == null) {
// LOGGER.warn("Merchant BBPS service is not active MID: {}", mid);
// return "Merchant BBPS Service is not active by mid";
// }
//
// if (!Boolean.TRUE.equals(merchantValidation.getIsActive())) {
// LOGGER.warn("Merchant inactive for MID: {}", mid);
// return "Merchant is inactive";
// }
//
// LOGGER.info("Merchant is valid and active for MID: {}", mid);
// return "Valid"; // Success message
// }
public void validateMerchant(String mid) {
if (mid == null || mid == "") {
LOGGER.warn("MerchantRequestModel or MID is null");
throw new CustomException("Invalid request: MID is required");
throw new CustomException("Mid is required", "FAILED", BBPSConstant.BADREQUEST, null);
}
// Fetch merchant details
BBPSMerchantValidation merchantValidation = merchantRegisterRepo.findByMid(requestModel.getMid());
BBPSMastersData merchantValidation = bbpsMasterDataRepo.findByMid(mid);
if (merchantValidation == null) {
LOGGER.warn("Merchant not found for MID: {}", requestModel.getMid());
throw new CustomException("Merchant not found");
LOGGER.warn("Merchant not found for MID: {}", mid);
throw new CustomException("Merchant not found by id", "FAILED", BBPSConstant.BADREQUEST, null);
}
if (!Boolean.TRUE.equals(merchantValidation.isActive())) {
LOGGER.warn("Merchant inactive for MID: {}", requestModel.getMid());
throw new CustomException("Merchant inactive");
if (merchantValidation.getApiKey() == null && merchantValidation.getSecreteKey() == null) {
LOGGER.warn("Merchant BBPS service is not active MID: {}", mid);
throw new CustomException("Merchant BBPS Service is not active by mid", "FAILED", BBPSConstant.BADREQUEST,
null);
}
LOGGER.info("Merchant is valid and active for MID: {}", requestModel.getMid());
return true;
}
public String validateMerchant(Object requestModel) {
if (!Boolean.TRUE.equals(merchantValidation.getIsActive())) {
LOGGER.warn("Merchant inactive for MID: {}", mid);
throw new CustomException("Merchant is inactive", "FAILED", BBPSConstant.BADREQUEST, null);
}
// if (requestModel == null || requestModel.getMid() == null) {
// LOGGER.warn("MerchantRequestModel or MID is null");
// return "Invalid request: MID is required";
// }
//
// // Fetch merchant details
// BBPSMerchantValidation merchant = merchantRegisterRepo.findByMid(requestModel.getMid());
//
// if (merchant == null) {
// LOGGER.warn("Merchant not found for MID: {}", requestModel.getMid());
// return "Merchant not found";
// }
//
// if (!Boolean.TRUE.equals(merchant.isActive())) {
// LOGGER.warn("Merchant inactive for MID: {}", requestModel.getMid());
// return "Merchant inactive";
// }
//
// LOGGER.info("Merchant is valid and active for MID: {}", requestModel.getMid());
return "Valid"; // Success message
LOGGER.info("Merchant is valid and active for MID: {}", mid);
// Agar exception nahi throw hua, merchant valid hai
}
public static String generateTxnId(int n) {
StringBuilder sb = new StringBuilder(n);
@@ -130,15 +169,17 @@ public class Helper {
}
return sb.toString(); // Prefix
}
public String convertObjectToJson(Object obj) {
if (obj == null) return "null";
try {
return new com.fasterxml.jackson.databind.ObjectMapper().writeValueAsString(obj);
} catch (com.fasterxml.jackson.core.JsonProcessingException e) {
// log appropriately (use your existing logger)
System.err.println("JSON conversion failed: " + e.getMessage());
return "{}"; // or "N/A" depending on your needs
}
if (obj == null)
return "null";
try {
return new com.fasterxml.jackson.databind.ObjectMapper().writeValueAsString(obj);
} catch (com.fasterxml.jackson.core.JsonProcessingException e) {
// log appropriately (use your existing logger)
System.err.println("JSON conversion failed: " + e.getMessage());
return "{}"; // or "N/A" depending on your needs
}
}
}
}