Merge pull request 'feature3' (#5) from feature3 into develop
Reviewed-on: https://git.zeptic.in/himanshu/bbps/pulls/5
This commit is contained in:
@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||
import com.billpaymentservice.bbps.dto.request.BillFetchByBillIdRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.FetchBillRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.FetchBillValidatestRequest;
|
||||
import com.billpaymentservice.bbps.service.AgentService;
|
||||
|
||||
@RestController
|
||||
@@ -49,5 +50,26 @@ public class AgentController {
|
||||
ResponseModel response = agentService.fetchBillById(billFetchByBillIdRequest);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches bill details validate from external BBPS service
|
||||
*/
|
||||
@PostMapping(value = "/requestBillValidate", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> requestBillValidate(
|
||||
@Validated @RequestBody FetchBillValidatestRequest fetchBillValidateRequest) {
|
||||
|
||||
ResponseModel response = agentService.initiateBillValidate(fetchBillValidateRequest);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches bill details by bill Id from external BBPS service
|
||||
*/
|
||||
@PostMapping(value = "/requestBillValidateByBillId", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> requestBillByBillId(@Validated @RequestBody BillFetchByBillIdRequest billRequest) {
|
||||
|
||||
ResponseModel response = agentService.initiateBillValidateByBillId(billRequest);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,35 +1,22 @@
|
||||
package com.billpaymentservice.bbps.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.MasterApiResponse;
|
||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||
import com.billpaymentservice.bbps.dto.request.BillerDetailRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.ContactMasterRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.CustomParamRequest;
|
||||
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.response.BillerDataResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.BillerResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.ContactMasterResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.CustomParamResp;
|
||||
import com.billpaymentservice.bbps.service.MasterDataService;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
@RequestMapping("/masterData")
|
||||
@RestController
|
||||
public class MasterDataController {
|
||||
@@ -41,39 +28,92 @@ public class MasterDataController {
|
||||
public MasterDataController(MasterDataService masterDataService) {
|
||||
this.masterDataService = masterDataService;
|
||||
}
|
||||
/**Get Details of the biller by billId **/
|
||||
|
||||
/** Get Details of the biller by billId **/
|
||||
@PostMapping(value = "/getBillerDetails", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> getBillerDetails(@Validated @RequestBody BillerDetailRequest billerDetailRequest) {
|
||||
public ResponseEntity<ResponseModel> getBillerDetails(
|
||||
@Validated @RequestBody BillerDetailRequest billerDetailRequest) {
|
||||
|
||||
log.info("Received biller details request for billerId: {}", billerDetailRequest.getBillerId());
|
||||
|
||||
return ResponseEntity.ok(masterDataService.getBillerByBillerId(billerDetailRequest));
|
||||
return ResponseEntity.ok(masterDataService.getBillerByBillerId(billerDetailRequest));
|
||||
}
|
||||
/**Get Master Contact**/
|
||||
|
||||
/** Get Master Contact **/
|
||||
@PostMapping(value = "/getContactMasterResponse", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> getContactMaster(
|
||||
@Validated @RequestBody ContactMasterRequest contactMasterRequest ) {
|
||||
@Validated @RequestBody ContactMasterRequest contactMasterRequest) {
|
||||
|
||||
return ResponseEntity.ok(masterDataService.getContactMaster(contactMasterRequest));
|
||||
return ResponseEntity.ok(masterDataService.getContactMaster(contactMasterRequest));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/getDispostionDetail", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> getDispostionDetail(
|
||||
@Validated @RequestBody ContactMasterRequest contactMasterRequest ) {
|
||||
return ResponseEntity.ok(masterDataService.getDispositionDetails());
|
||||
@Validated @RequestBody ContactMasterRequest contactMasterRequest) {
|
||||
return ResponseEntity.ok(masterDataService.getDispositionDetails());
|
||||
}
|
||||
|
||||
|
||||
/** Get CustomerParam by billerId.The parameter is different from the data we are getting in the billerDetail **/
|
||||
|
||||
/**
|
||||
* Get CustomerParam by billerId.The parameter is different from the data we are
|
||||
* getting in the billerDetail
|
||||
**/
|
||||
|
||||
@PostMapping(value = "/getCustomerParamDetails", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> getCustomerParamDetails(
|
||||
@Validated @RequestBody CustomParamRequest customerParamRequest) {
|
||||
|
||||
log.info("Received biller details request for billerId: {}",customerParamRequest.getBillerId() );
|
||||
log.info("Received biller details request for billerId: {}", customerParamRequest.getBillerId());
|
||||
|
||||
return ResponseEntity.ok(masterDataService.getCustomerParamByBillerId(customerParamRequest));
|
||||
return ResponseEntity.ok(masterDataService.getCustomerParamByBillerId(customerParamRequest));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get All Master Data .The parameter is different from the data we are getting
|
||||
* in the MasterRequest
|
||||
**/
|
||||
@PostMapping("/getAllMastersData")
|
||||
public ResponseModel fetchMasterData(@Validated @RequestBody MasterRequest masterRequest) {
|
||||
return masterDataService.getMasterData(masterRequest);
|
||||
}
|
||||
|
||||
/** POST Master Category Wise API Fetch Category Wise from BBPS URL **/
|
||||
@PostMapping(value = "/getMasterCategoryWise", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> getMasterDataCategoryWise(
|
||||
@Validated @RequestBody MasterCategoryRequest masterRequest) {
|
||||
return ResponseEntity.ok(masterDataService.fetchMasterDataCategoryWise(masterRequest));
|
||||
}
|
||||
|
||||
/** POST Customer Param Groups API Fetch Category Wise from BBPS URL **/
|
||||
@PostMapping(value = "/customerParamGroups", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> getCustomerParamGroup(
|
||||
@Validated @RequestBody BillerDetailRequest requestModel) {
|
||||
return ResponseEntity.ok(masterDataService.fetchCustomerParamGroup(requestModel));
|
||||
}
|
||||
|
||||
/**
|
||||
* POST Fetch All AMount Options By Biller Id API Fetch Category Wise from BBPS
|
||||
* URL
|
||||
**/
|
||||
@PostMapping(value = "/fetchAllAmountOptionsByBillerId", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> fetchAllMasterAmountOptionsByBillerId(
|
||||
@Validated @RequestBody BillerDetailRequest requestModel) {
|
||||
return ResponseEntity.ok(masterDataService.fetchAllMasterAmountOption(requestModel));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
public ResponseEntity<ResponseModel> fetchPlanCategories(@Validated @RequestBody BillerDetailRequest requestModel) {
|
||||
return ResponseEntity.ok(masterDataService.fetchPlanCategorie(requestModel));
|
||||
}
|
||||
|
||||
/**
|
||||
* POST Fetch Initiating Channel API Fetch Category Wise from BBPS URL
|
||||
**/
|
||||
@PostMapping(value = "/initiatingChannel", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> initiatingChannel(@Validated @RequestBody BillerDetailRequest requestModel) {
|
||||
return ResponseEntity.ok(masterDataService.fetchInitiatingChannel(requestModel));
|
||||
}
|
||||
}
|
||||
|
||||
+6
-8
@@ -1,21 +1,19 @@
|
||||
package com.billpaymentservice.bbps.dto;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class GeneralResponse {
|
||||
@AllArgsConstructor
|
||||
public class ChannelDTO {
|
||||
|
||||
private String statusCode;
|
||||
private String status;
|
||||
private String message;
|
||||
private String remarks;
|
||||
private UUID channelId; // Machine-generated Unique ID assigned internally
|
||||
private String channelName;
|
||||
|
||||
}
|
||||
@@ -8,12 +8,14 @@ import java.util.List;
|
||||
@Setter
|
||||
public class GroupDTO {
|
||||
|
||||
private String name;
|
||||
private String groupId;
|
||||
|
||||
private String name;
|
||||
|
||||
private String input;
|
||||
private String input;
|
||||
|
||||
private List<String> params;
|
||||
private List<String> params;
|
||||
|
||||
// 🔁 Nested child groups
|
||||
private List<GroupDTO> groups;
|
||||
// 🔁 Nested child groups
|
||||
private List<GroupDTO> groups;
|
||||
}
|
||||
|
||||
@@ -11,11 +11,8 @@ import lombok.Setter;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class BillFetchByBillIdRequest extends BaseClass {
|
||||
|
||||
|
||||
@NotNull
|
||||
private String billId;
|
||||
private String tenantId;
|
||||
private String digiledgeKey;
|
||||
private String agentId;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.billpaymentservice.bbps.dto.request;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.CustomerParamsRequest;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class FetchBillValidatestRequest extends BaseClass {
|
||||
|
||||
@NotNull
|
||||
private String billerId; // Alphanumeric, Unique ID assigned by NPCI
|
||||
@NotNull
|
||||
private String billerName; // String, Name of the biller
|
||||
@NotNull
|
||||
private String billerCategory; // String, Category of the biller
|
||||
@NotNull
|
||||
private String customerMobNo; // String, Mobile of the Customer
|
||||
|
||||
// Optional Fields
|
||||
private String macAddress; // Alphanumeric MAC Address of the Agent Server
|
||||
//private String clientReqId; // String, Unique id provided by the client
|
||||
private CustomerParamsRequest customerParamsRequest; // Customer parameters for identifying the bill
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.billpaymentservice.bbps.dto.request;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class MasterCategoryRequest extends BaseClass {
|
||||
|
||||
private String billerName;
|
||||
|
||||
@NotNull
|
||||
private String category;
|
||||
|
||||
private Integer pageStart = 0;
|
||||
|
||||
private Integer pageEnd = 10;
|
||||
|
||||
}
|
||||
@@ -1,15 +1,12 @@
|
||||
package com.billpaymentservice.bbps.dto.request;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
|
||||
public class MasterRequest extends BaseClass {
|
||||
@NotNull
|
||||
private String tenantId;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.billpaymentservice.bbps.dto.response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.AmountOptionDTO;
|
||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AmountOptionsResponse {
|
||||
|
||||
// Root element, no parent
|
||||
@JsonProperty("amountOptions")
|
||||
private Boolean amountOptions;
|
||||
|
||||
@JsonProperty("amountOptionDAOS")
|
||||
private List<AmountOptionDTO> amountOptionDAOS;
|
||||
|
||||
@JsonProperty("generalResp")
|
||||
private GeneralResp generalResp;
|
||||
}
|
||||
@@ -6,8 +6,8 @@ import com.billpaymentservice.bbps.dto.AdditionalInfoBill;
|
||||
import com.billpaymentservice.bbps.dto.BillerResponseBill;
|
||||
import com.billpaymentservice.bbps.dto.CustomerParamDAO;
|
||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||
import com.billpaymentservice.bbps.dto.GeneralResponse;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
@@ -20,21 +20,22 @@ import lombok.Setter;
|
||||
@NoArgsConstructor
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class BillDataResponse {
|
||||
|
||||
private GeneralResp genericResponse;
|
||||
private String billId;
|
||||
private String refId;
|
||||
private String billerId;
|
||||
private String status;
|
||||
private String actionType;
|
||||
private String userId;
|
||||
|
||||
private BillerResponseBill billerResponse; // nested object
|
||||
private List<AdditionalInfoBill> additionalInfo; // array of objects
|
||||
private List<CustomerParamDAO> customerParams; // array of objects
|
||||
|
||||
private String creationDate;
|
||||
private String modifiedDate;
|
||||
private long createdEpochDate;
|
||||
private long modifiedEpochDate;
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private GeneralResp genericResponse;
|
||||
private String billId;
|
||||
private String refId;
|
||||
private String billerId;
|
||||
private String status;
|
||||
private String actionType;
|
||||
private String userId;
|
||||
|
||||
private BillerResponseBill billerResponse; // nested object
|
||||
private List<AdditionalInfoBill> additionalInfo; // array of objects
|
||||
private List<CustomerParamDAO> customerParams; // array of objects
|
||||
|
||||
private String creationDate;
|
||||
private String modifiedDate;
|
||||
private long createdEpochDate;
|
||||
private long modifiedEpochDate;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.billpaymentservice.bbps.dto.response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.GeneralResponse;
|
||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||
import com.billpaymentservice.bbps.dto.MasterCategoryBillerResponse;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -20,7 +20,7 @@ public class BillerResponse {
|
||||
private int pageSize;
|
||||
private long totalElements;
|
||||
private int totalPages;
|
||||
private GeneralResponse generalResp;
|
||||
private GeneralResp generalResp;
|
||||
private List<MasterCategoryBillerResponse> billerResp;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.billpaymentservice.bbps.dto.response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.ChannelDTO;
|
||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ChannelsListResponse {
|
||||
|
||||
private List<ChannelDTO> channelList;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private GeneralResp genericResp;
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.billpaymentservice.bbps.dto.response;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.CustomerParamGroupsDTO;
|
||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CustomerParamGroupsResponse {
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private GeneralResp generalResp;
|
||||
|
||||
private CustomerParamGroupsDTO customerParamGroupResp;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.billpaymentservice.bbps.dto.response;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.GeneralResponse;
|
||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -14,7 +14,7 @@ import lombok.Setter;
|
||||
@NoArgsConstructor
|
||||
public class FetchBillResponse {
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private GeneralResponse genericResponse;
|
||||
private GeneralResp genericResponse;
|
||||
private String billId;
|
||||
private String refId;
|
||||
private String billerId;
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.billpaymentservice.bbps.dto.response;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class FetchBillValidatestResponse {
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private GeneralResp genericResponse;
|
||||
private String billId;
|
||||
private String refId;
|
||||
private String billerId;
|
||||
private String status;
|
||||
private String actionType;
|
||||
private String userId;
|
||||
private String billerResponse;
|
||||
private String additionalInfo;
|
||||
private String customerParams;
|
||||
private String planInfoDaos;
|
||||
private String creationDate;
|
||||
private String modifiedDate;
|
||||
private long createdEpochDate;
|
||||
private long modifiedEpochDate;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.billpaymentservice.bbps.dto.response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PlaneCategoriesResponse {
|
||||
|
||||
private List<String> categoryRespList;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private GeneralResp generalResp;
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.billpaymentservice.bbps.service;
|
||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||
import com.billpaymentservice.bbps.dto.request.BillFetchByBillIdRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.FetchBillRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.FetchBillValidatestRequest;
|
||||
|
||||
public interface AgentService {
|
||||
|
||||
@@ -10,4 +11,8 @@ public interface AgentService {
|
||||
|
||||
public ResponseModel fetchBillById(BillFetchByBillIdRequest billFetchByBillIdRequest);
|
||||
|
||||
public ResponseModel initiateBillValidate(FetchBillValidatestRequest fetchBillValidateRequest);
|
||||
|
||||
public ResponseModel initiateBillValidateByBillId(BillFetchByBillIdRequest billRequest);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.billpaymentservice.bbps.service;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||
import com.billpaymentservice.bbps.dto.request.BillerDetailRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.ContactMasterRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.CustomParamRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.MasterCategoryRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.MasterRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.MerchantRequestModel;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
@@ -11,10 +13,22 @@ public interface MasterDataService {
|
||||
|
||||
public ResponseModel getBillerByBillerId(BillerDetailRequest billerDetailRequest);
|
||||
|
||||
public ResponseModel getMasterData(MasterRequest masterRequest);
|
||||
|
||||
public ResponseModel getCustomerParamByBillerId(CustomParamRequest customerParamRequest);
|
||||
|
||||
public ResponseModel getContactMaster(ContactMasterRequest contactMasterRequest);
|
||||
|
||||
public ResponseModel fetchMasterDataCategoryWise(MasterCategoryRequest masterRequest);
|
||||
|
||||
public ResponseModel fetchCustomerParamGroup(BillerDetailRequest requestModel);
|
||||
|
||||
public ResponseModel fetchAllMasterAmountOption(BillerDetailRequest requestModel);
|
||||
|
||||
public ResponseModel fetchPlanCategorie(BillerDetailRequest requestModel);
|
||||
|
||||
public ResponseModel fetchInitiatingChannel(BillerDetailRequest requestModel);
|
||||
|
||||
public ResponseModel getDispositionDetails();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
package com.billpaymentservice.bbps.serviceImpl;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
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.GeneralResponse;
|
||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||
import com.billpaymentservice.bbps.dto.request.BillFetchByBillIdRequest;
|
||||
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.BillerDataResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.FetchBillResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.FetchBillValidatestResponse;
|
||||
import com.billpaymentservice.bbps.entites.BharatConnectMaster;
|
||||
import com.billpaymentservice.bbps.exception.CustomException;
|
||||
import com.billpaymentservice.bbps.repository.BharatConnectMasterRepository;
|
||||
@@ -18,175 +26,270 @@ 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.RequiredArgsConstructor;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestClient;
|
||||
import org.springframework.web.servlet.function.ServerRequest.Headers;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AgentServiceImpl implements AgentService {
|
||||
|
||||
@Value("${agent.data.url}")
|
||||
private String agentDtaUrl;
|
||||
|
||||
private final RestClient restClient;
|
||||
private final HttpService httpService;
|
||||
private final Helper helper;
|
||||
private final BharatConnectMasterRepository beneficiaryDetailsRepository;
|
||||
|
||||
public AgentServiceImpl(RestClient restClient,HttpService httpService,Helper helper, BharatConnectMasterRepository beneficiaryDetailsRepository) {
|
||||
this.restClient=restClient;
|
||||
this.httpService=httpService;
|
||||
this.helper=helper;
|
||||
this.beneficiaryDetailsRepository=beneficiaryDetailsRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel initiateBillFetch(FetchBillRequest fetchBillRequest) {
|
||||
String url = agentDtaUrl + BBPSConstant.BILL_FETCH_INTI;
|
||||
System.out.println(url);
|
||||
|
||||
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);
|
||||
ResponseModel responseModel = new ResponseModel();
|
||||
|
||||
try {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
private final RestClient restClient;
|
||||
private final HttpService httpService;
|
||||
private final Helper helper;
|
||||
private final BharatConnectMasterRepository beneficiaryDetailsRepository;
|
||||
|
||||
// ✅ 1st API Call
|
||||
String json = objectMapper.writeValueAsString(fetchBillRequest);
|
||||
Map<String, String> responseMap = httpService.postRequest(url, json, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
public AgentServiceImpl(RestClient restClient, HttpService httpService, Helper helper,
|
||||
BharatConnectMasterRepository beneficiaryDetailsRepository) {
|
||||
this.restClient = restClient;
|
||||
this.httpService = httpService;
|
||||
this.helper = helper;
|
||||
this.beneficiaryDetailsRepository = beneficiaryDetailsRepository;
|
||||
}
|
||||
|
||||
log.info("📦 1st API Response: {}", responseData);
|
||||
@Override
|
||||
public ResponseModel initiateBillFetch(FetchBillRequest fetchBillRequest) {
|
||||
String url = agentDtaUrl + BBPSConstant.BILL_FETCH_INTI;
|
||||
System.out.println(url);
|
||||
|
||||
if (responseData == null || responseData.isEmpty()) {
|
||||
throw new CustomException("Empty response from BBPS server");
|
||||
}
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
|
||||
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
throw new CustomException("Invalid response structure from BBPS");
|
||||
}
|
||||
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);
|
||||
|
||||
FetchBillResponse fetchBillResponse = objectMapper.convertValue(dataMap, FetchBillResponse.class);
|
||||
ResponseModel responseModel = new ResponseModel();
|
||||
|
||||
// ✅ IMMEDIATE 2nd API CALL (SYNCHRONOUS)
|
||||
BillFetchByBillIdRequest pollReq = new BillFetchByBillIdRequest();
|
||||
pollReq.setBillId(fetchBillResponse.getBillId());
|
||||
|
||||
// ✅ This will wait for the response
|
||||
ResponseModel secondApiResponse = fetchBillById(pollReq);
|
||||
|
||||
// ✅ Return directly the second API response
|
||||
return secondApiResponse;
|
||||
try {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("❌ Exception in initiateBillFetch(): {}", e.getMessage(), e);
|
||||
responseModel.setStatus("500");
|
||||
responseModel.setMessage("Exception occurred");
|
||||
responseModel.setData(e.getMessage());
|
||||
return responseModel;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel fetchBillById(BillFetchByBillIdRequest billFetchByBillIdRequest) {
|
||||
// ✅ Convert request to JSON
|
||||
String json = objectMapper.writeValueAsString(fetchBillRequest);
|
||||
|
||||
String billId = billFetchByBillIdRequest.getBillId();
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + "1ced7566-1add-4e01-9ed6-04cd67ac9684";
|
||||
// String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + billId;
|
||||
// ✅ Call the API using httpService
|
||||
Map<String, String> responseMap = httpService.postRequest(url, json, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
|
||||
System.out.print(fullUrl);
|
||||
log.info("📦 Bill Fetch API Response: {}", responseData);
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
if (responseData == null || responseData.isEmpty()) {
|
||||
throw new CustomException("Empty response from BBPS server");
|
||||
}
|
||||
|
||||
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 JSON string → Map
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
// ✅ Validate generalResp
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
throw new CustomException("Invalid response structure from BBPS");
|
||||
}
|
||||
|
||||
int maxWaitTimeMs = 40000; // 40 seconds
|
||||
int intervalMs = 6000; // 3 seconds
|
||||
long startTime = System.currentTimeMillis();
|
||||
// ✅ Convert to your custom DTO
|
||||
FetchBillResponse fetchBillResponse = objectMapper.convertValue(dataMap, FetchBillResponse.class);
|
||||
GeneralResp generalResponse = fetchBillResponse.getGenericResponse();
|
||||
//
|
||||
// start a new thread here
|
||||
helper.startPolling(fetchBillResponse, res -> {
|
||||
BillFetchByBillIdRequest pollReq = new BillFetchByBillIdRequest();
|
||||
pollReq.setBillId(res.getBillId());
|
||||
return fetchBillById(pollReq);
|
||||
}, 3, // interval in seconds
|
||||
15 // total time in seconds
|
||||
);
|
||||
|
||||
while (true) {
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
log.info("data is :{}", responseData);
|
||||
// ✅ Build final ResponseModel
|
||||
responseModel = new ResponseModel(generalResponse.getMessage(), generalResponse.getStatus(),
|
||||
Integer.parseInt(generalResponse.getStatusCode()), fetchBillResponse);
|
||||
|
||||
try {
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
} catch (Exception e) {
|
||||
log.error("❌ Exception in initiateBillFetch(): {}", e.getMessage(), e);
|
||||
responseModel.setStatus("500");
|
||||
responseModel.setMessage("Exception occurred");
|
||||
responseModel.setData(e.getMessage());
|
||||
}
|
||||
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
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"))
|
||||
);
|
||||
}
|
||||
return responseModel;
|
||||
}
|
||||
|
||||
BillDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillDataResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||
@Override
|
||||
public ResponseModel fetchBillById(BillFetchByBillIdRequest billFetchByBillIdRequest) {
|
||||
|
||||
String status = generalResp.getStatus();
|
||||
String billId = billFetchByBillIdRequest.getBillId();
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + billId;
|
||||
System.out.print(fullUrl);
|
||||
|
||||
// ✅ Agar status "IN_PROGRESS" hai to wait and retry
|
||||
if ("INPROGRESS".equalsIgnoreCase(status)) {
|
||||
if (System.currentTimeMillis() - startTime > maxWaitTimeMs) {
|
||||
// 40 sec ke baad bhi IN_PROGRESS -> Timeout exception
|
||||
throw new CustomException("Timeout waiting for bill fetch completion",
|
||||
"FAILED", 408, "Bill fetch still in progress after 40 seconds");
|
||||
}
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
|
||||
try {
|
||||
Thread.sleep(intervalMs);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new CustomException("Thread interrupted during retry");
|
||||
}
|
||||
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);
|
||||
|
||||
log.info("Bill still in progress... retrying after {} seconds", (intervalMs / 1000));
|
||||
continue; // retry again
|
||||
}
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
log.info("data is :{}", responseData);
|
||||
|
||||
// ✅ Agar status IN_PROGRESS nahi hai (e.g., SUCCESS / FAILED), return result
|
||||
ResponseModel responseModel = new ResponseModel(
|
||||
generalResp.getMessage(),
|
||||
generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()),
|
||||
responseWrapper
|
||||
);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
return responseModel;
|
||||
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")));
|
||||
}
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
}
|
||||
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) {
|
||||
log.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel initiateBillValidate(FetchBillValidatestRequest fetchBillValidateRequest) {
|
||||
|
||||
ResponseModel responseModel = new ResponseModel();
|
||||
try {
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
|
||||
if (headersData == null) {
|
||||
responseModel = new ResponseModel("Tenant Id Is Null", "Not Found", BBPSConstant.BADREQUEST,
|
||||
headersData);
|
||||
return responseModel;
|
||||
}
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
String json = objectMapper.writeValueAsString(fetchBillValidateRequest);
|
||||
String url = agentDtaUrl + BBPSConstant.BILLER_VALIDATE_URL;
|
||||
Map<String, String> responseMap = httpService.postRequest(url, json, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
|
||||
log.info("📦 Bill Fetch API Response: {}", responseData);
|
||||
|
||||
if (responseData == null || responseData.isEmpty()) {
|
||||
throw new CustomException("Empty response from BBPS server");
|
||||
}
|
||||
|
||||
// ✅ Convert JSON string → Map
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
// ✅ Validate generalResp
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
throw new CustomException("Invalid response structure from BBPS");
|
||||
}
|
||||
|
||||
// ✅ Convert to your custom DTO
|
||||
FetchBillValidatestResponse fetchBillResponse = objectMapper.convertValue(dataMap,
|
||||
FetchBillValidatestResponse.class);
|
||||
GeneralResp generalResponse = fetchBillResponse.getGenericResponse();
|
||||
|
||||
// ✅ Build final ResponseModel
|
||||
responseModel = new ResponseModel(generalResponse.getMessage(), generalResponse.getStatus(),
|
||||
Integer.parseInt(generalResponse.getStatusCode()), fetchBillResponse);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("❌ Exception in initiateBillFetch(): {}", e.getMessage(), e);
|
||||
responseModel.setStatus("500");
|
||||
responseModel.setMessage("Exception occurred");
|
||||
responseModel.setData(e.getMessage());
|
||||
}
|
||||
|
||||
return responseModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel initiateBillValidateByBillId(BillFetchByBillIdRequest billRequest) {
|
||||
|
||||
ResponseModel responseModel = new ResponseModel();
|
||||
try {
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
|
||||
if (headersData == null) {
|
||||
responseModel = new ResponseModel("Tenant Id Is Null", "Not Found", BBPSConstant.BADREQUEST,
|
||||
headersData);
|
||||
return responseModel;
|
||||
}
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
String json = objectMapper.writeValueAsString(billRequest);
|
||||
String url = agentDtaUrl + BBPSConstant.BILL_ID_URL + billRequest.getBillId();
|
||||
|
||||
log.info("Full URL" + url);
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
|
||||
// ✅ Call the API using httpService
|
||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
|
||||
log.info("📦 Bill Fetch API Response: {}", responseData);
|
||||
|
||||
if (responseData == null || responseData.isEmpty()) {
|
||||
throw new CustomException("Empty response from BBPS server");
|
||||
}
|
||||
|
||||
// ✅ Convert JSON string → Map
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
// ✅ Validate generalResp
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
throw new CustomException("Invalid response structure from BBPS");
|
||||
}
|
||||
|
||||
// ✅ Convert to your custom DTO
|
||||
BillDataResponse fetchBillResponse = objectMapper.convertValue(dataMap, BillDataResponse.class);
|
||||
GeneralResp generalResponse = fetchBillResponse.getGenericResponse();
|
||||
|
||||
// ✅ Build final ResponseModel
|
||||
responseModel = new ResponseModel(generalResponse.getRemarks(), generalResponse.getStatus(),
|
||||
Integer.parseInt(generalResponse.getStatusCode()), fetchBillResponse);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("❌ Exception in initiateBillFetch(): {}", e.getMessage(), e);
|
||||
responseModel.setStatus("500");
|
||||
responseModel.setMessage("Exception occurred");
|
||||
responseModel.setData(e.getMessage());
|
||||
}
|
||||
|
||||
return responseModel;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -124,11 +124,12 @@ public class HttpService {
|
||||
.headers(h -> h.addAll(headers))
|
||||
.retrieve()
|
||||
.toEntity(String.class);
|
||||
|
||||
|
||||
response.put("respCode", String.valueOf(restResponse.getStatusCode().value()));
|
||||
response.put("data", restResponse.getBody());
|
||||
|
||||
log.info("✅ GET Response: {}", restResponse.getStatusCode());
|
||||
log.info("✅ GET Response: {}", restResponse.getBody());
|
||||
|
||||
} catch (HttpClientErrorException | HttpServerErrorException httpException) {
|
||||
log.error("❌ HTTP Error: {}", httpException.getMessage(), httpException);
|
||||
|
||||
+375
-117
@@ -1,10 +1,7 @@
|
||||
package com.billpaymentservice.bbps.serviceImpl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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,31 +11,27 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.DispositionsDTO;
|
||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||
import com.billpaymentservice.bbps.dto.MasterApiResponse;
|
||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||
import com.billpaymentservice.bbps.dto.request.BillerDetailRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.ContactMasterRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.CustomParamRequest;
|
||||
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.response.AmountOptionsResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.BillerDataResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.BillerResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.CategoryResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.ContactMasterResponse;
|
||||
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.entites.AmountOption;
|
||||
import com.billpaymentservice.bbps.entites.BBPSMerchantValidation;
|
||||
import com.billpaymentservice.bbps.entites.BillPayment;
|
||||
import com.billpaymentservice.bbps.dto.response.PlaneCategoriesResponse;
|
||||
import com.billpaymentservice.bbps.entites.BharatConnectMaster;
|
||||
import com.billpaymentservice.bbps.entites.BillerDetails;
|
||||
import com.billpaymentservice.bbps.entites.BillerResponseParams;
|
||||
import com.billpaymentservice.bbps.entites.DispositionDetails;
|
||||
import com.billpaymentservice.bbps.entites.InterchangeFee;
|
||||
import com.billpaymentservice.bbps.entites.InterchangeFeeDetail;
|
||||
import com.billpaymentservice.bbps.exception.AppException;
|
||||
import com.billpaymentservice.bbps.exception.CustomException;
|
||||
import com.billpaymentservice.bbps.repository.BharatConnectMasterRepository;
|
||||
import com.billpaymentservice.bbps.repository.BillerDataRepository;
|
||||
import com.billpaymentservice.bbps.repository.DispositionRepository;
|
||||
import com.billpaymentservice.bbps.repository.MerchantRepository;
|
||||
@@ -50,8 +43,6 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
@Service
|
||||
public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
@@ -59,82 +50,82 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
@Value("${master.data.url}")
|
||||
private String masterRegisterUrl;
|
||||
private final BharatConnectMasterRepository beneficiaryDetailsRepository;
|
||||
|
||||
private MerchantRepository merchantRegisterRepo;
|
||||
private HttpClientApi httpClientApi;
|
||||
private final DispositionRepository dispositionRepository;
|
||||
private final Helper helper;
|
||||
private final BillerDataRepository billerDataRespository;
|
||||
private final BillerDataRepository billerDataRespository;
|
||||
private static final Logger log = LoggerFactory.getLogger(MasterDataServiceImpl.class);
|
||||
private final HttpService httpService;
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
// Inject HttpService
|
||||
public MasterDataServiceImpl(MerchantRepository merchantRegisterRepo,
|
||||
HttpService httpService,
|
||||
HttpClientApi httpClientApi,
|
||||
Helper helper,
|
||||
BillerDataRepository billerDataRespository,
|
||||
DispositionRepository dispositionRepository
|
||||
) {
|
||||
this.merchantRegisterRepo = merchantRegisterRepo;
|
||||
this.httpService = httpService;
|
||||
this.httpClientApi = httpClientApi;
|
||||
this.helper = helper;
|
||||
this.billerDataRespository=billerDataRespository;
|
||||
this.dispositionRepository=dispositionRepository;
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public ResponseModel getBillerByBillerId(BillerDetailRequest billerDetailRequest) {
|
||||
|
||||
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);
|
||||
public MasterDataServiceImpl(MerchantRepository merchantRegisterRepo, HttpService httpService,
|
||||
HttpClientApi httpClientApi, Helper helper, BillerDataRepository billerDataRespository,
|
||||
DispositionRepository dispositionRepository, BharatConnectMasterRepository beneficiaryDetailsRepository) {
|
||||
this.merchantRegisterRepo = merchantRegisterRepo;
|
||||
this.httpService = httpService;
|
||||
this.httpClientApi = httpClientApi;
|
||||
this.helper = helper;
|
||||
this.billerDataRespository = billerDataRespository;
|
||||
this.dispositionRepository = dispositionRepository;
|
||||
this.beneficiaryDetailsRepository = beneficiaryDetailsRepository;
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
try {
|
||||
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")) );
|
||||
}
|
||||
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);
|
||||
// billerDataRespository.save(entity);
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel getMasterData(MasterRequest masterRequest) {
|
||||
LOGGER.info("Request DTO: {}", masterRequest);
|
||||
|
||||
try {
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
log.info("ResPONSE" + headersData);
|
||||
if (headersData == null) {
|
||||
ResponseModel responseModel = new ResponseModel("Tenant Id Is Null", "Not Found",
|
||||
BBPSConstant.BADREQUEST, headersData);
|
||||
return responseModel;
|
||||
}
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.MASTER_CATEGORY_URL + headersData.getTenantId();
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("Response Data: {}", responseData);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
// ✅ Same check as in getBillerByBillerId()
|
||||
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
|
||||
String.valueOf(dataMap.get("remarks")) // remarks
|
||||
);
|
||||
}
|
||||
|
||||
MasterApiResponse responseWrapper = objectMapper.convertValue(dataMap, MasterApiResponse.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");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel getCustomerParamByBillerId(CustomParamRequest customerParamRequest) {
|
||||
String billerId = customerParamRequest.getBillerId();
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.CUSTOMPARAM_URL+billerId;
|
||||
public ResponseModel getBillerByBillerId(BillerDetailRequest billerDetailRequest) {
|
||||
|
||||
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");
|
||||
@@ -147,39 +138,128 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
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")) );
|
||||
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")));
|
||||
}
|
||||
|
||||
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);
|
||||
// billerDataRespository.save(entity);
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel getCustomerParamByBillerId(CustomParamRequest customerParamRequest) {
|
||||
|
||||
try {
|
||||
|
||||
String billerId = customerParamRequest.getBillerId();
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.CUSTOMPARAM_URL + billerId;
|
||||
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||
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>>() {
|
||||
});
|
||||
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")));
|
||||
}
|
||||
|
||||
CustomParamResp responseWrapper = objectMapper.convertValue(dataMap, CustomParamResp.class);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
|
||||
ResponseModel responseModel=new ResponseModel( generalResp.getMessage(),
|
||||
generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()),
|
||||
responseWrapper);
|
||||
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel getContactMaster(ContactMasterRequest contactMasterRequest) {
|
||||
|
||||
|
||||
return new ResponseModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel fetchMasterDataCategoryWise(MasterCategoryRequest masterRequest) {
|
||||
LOGGER.info("Fetching Master Data Category-wise " + masterRequest);
|
||||
|
||||
try {
|
||||
|
||||
String validateMerchant = helper.validateMerchant(masterRequest);
|
||||
|
||||
if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
||||
LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
||||
return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
|
||||
}
|
||||
|
||||
String fullUrl = String.format("%s%s?billerName=%s&category=%s&page=%d&pagesize=%d", masterRegisterUrl,
|
||||
BBPSConstant.BILLER_URL, masterRequest.getBillerName(), masterRequest.getCategory(),
|
||||
masterRequest.getPageStart(), masterRequest.getPageEnd());
|
||||
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("Response Data: {}", responseData);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
// ✅ Same check as in getBillerByBillerId()
|
||||
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
|
||||
String.valueOf(dataMap.get("remarks")) // remarks
|
||||
);
|
||||
}
|
||||
|
||||
BillerResponse responseWrapper = objectMapper.convertValue(dataMap, BillerResponse.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");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel getDispositionDetails() {
|
||||
String fullUrl=masterRegisterUrl+BBPSConstant.DISPOSTION_URL;
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.DISPOSTION_URL;
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||
String responseData = responseMap.get("data");
|
||||
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
try {
|
||||
@@ -187,42 +267,220 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
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")) );
|
||||
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")));
|
||||
}
|
||||
|
||||
|
||||
DispositionResponse responseWrapper = objectMapper.convertValue(dataMap, DispositionResponse.class);
|
||||
System.out.println(responseWrapper);
|
||||
System.out.println(responseWrapper);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
ModelMapper mapper = new ModelMapper();
|
||||
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||
List<DispositionDetails> entities = responseWrapper.getDispositionsList()
|
||||
.stream()
|
||||
.map(dto -> mapper.map(dto, DispositionDetails.class))
|
||||
.collect(Collectors.toList());
|
||||
List<DispositionDetails> entities = responseWrapper.getDispositionsList().stream()
|
||||
.map(dto -> mapper.map(dto, DispositionDetails.class)).collect(Collectors.toList());
|
||||
|
||||
System.out.println(entities);
|
||||
|
||||
if (entities != null)
|
||||
{
|
||||
dispositionRepository.saveAll(entities);
|
||||
}
|
||||
else {
|
||||
LOGGER.warn("No disposition found in response to save.");
|
||||
}
|
||||
|
||||
ResponseModel responseModel=new ResponseModel( generalResp.getMessage(),
|
||||
generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()),
|
||||
responseWrapper);
|
||||
|
||||
|
||||
if (entities != null) {
|
||||
dispositionRepository.saveAll(entities);
|
||||
} else {
|
||||
LOGGER.warn("No disposition found in response to save.");
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel fetchCustomerParamGroup(BillerDetailRequest requestModel) {
|
||||
LOGGER.info("Fetching Master Data Category-wise for MID={}", requestModel.getMid());
|
||||
|
||||
try {
|
||||
|
||||
String validateMerchant = helper.validateMerchant(requestModel);
|
||||
|
||||
if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
||||
LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
||||
return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
|
||||
}
|
||||
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.CUSTOMER_PARAM_GROUP + requestModel.getBillerId();
|
||||
// LOGGER.info("Calling Master API: {}", fullUrl);
|
||||
|
||||
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
|
||||
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")));
|
||||
}
|
||||
|
||||
CustomerParamGroupsResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||
CustomerParamGroupsResponse.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");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel fetchAllMasterAmountOption(BillerDetailRequest requestModel) {
|
||||
LOGGER.info("Fetching Master Data Amount List for MID={}", requestModel.getMid());
|
||||
try {
|
||||
String validateMerchant = helper.validateMerchant(requestModel);
|
||||
|
||||
if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
||||
LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
||||
return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
|
||||
}
|
||||
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.AMOUNT_OPTIONS + requestModel.getBillerId();
|
||||
// LOGGER.info("Calling Master API: {}", fullUrl);
|
||||
|
||||
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
|
||||
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")));
|
||||
}
|
||||
|
||||
AmountOptionsResponse responseWrapper = objectMapper.convertValue(dataMap, AmountOptionsResponse.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
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel fetchPlanCategorie(BillerDetailRequest requestModel) {
|
||||
LOGGER.info("Fetching Master Data Amount List for MID={}", requestModel.getMid());
|
||||
try {
|
||||
String validateMerchant = helper.validateMerchant(requestModel);
|
||||
|
||||
if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
||||
LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
||||
return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
|
||||
}
|
||||
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.PLAN_CATEGORIES + requestModel.getBillerId();
|
||||
// LOGGER.info("Calling Master API: {}", fullUrl);
|
||||
|
||||
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
|
||||
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")));
|
||||
}
|
||||
|
||||
PlaneCategoriesResponse responseWrapper = objectMapper.convertValue(dataMap, PlaneCategoriesResponse.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
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel fetchInitiatingChannel(BillerDetailRequest requestModel) {
|
||||
LOGGER.info("Fetching Initiating Channel List for MID={}", requestModel.getMid());
|
||||
try {
|
||||
String validateMerchant = helper.validateMerchant(requestModel);
|
||||
|
||||
if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
||||
LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
||||
return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
|
||||
}
|
||||
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.INITIATING_CHANNEL;
|
||||
LOGGER.info("Calling Master API: {}", fullUrl);
|
||||
|
||||
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
|
||||
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")));
|
||||
}
|
||||
|
||||
ChannelsListResponse responseWrapper = objectMapper.convertValue(dataMap, ChannelsListResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGenericResp();
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||
import com.billpaymentservice.bbps.dto.GeneralResponse;
|
||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||
import com.billpaymentservice.bbps.dto.request.BillFetchByBillIdRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
|
||||
|
||||
@@ -8,6 +8,7 @@ public class BBPSConstant {
|
||||
public static final Long SCHEDULER_CODE = 222L;
|
||||
public static final Long PENDING_CODE = 211L;
|
||||
public static final Long FRAUD_CODE = 1001L;
|
||||
public static final int BADREQUEST = 400;
|
||||
|
||||
public static final String SUCCESS_STATUS = "success";
|
||||
public static final String FAILED_STATUS = "failed";
|
||||
@@ -25,13 +26,21 @@ public class BBPSConstant {
|
||||
|
||||
public static final String BILLER_URL = "/billers";
|
||||
public static final String MASTER_CATEGORY_URL = "/categories-master?tenantId=";
|
||||
|
||||
public static final String BILLER_DATA_FETCH_URL="/billersById?billerId=";
|
||||
public static final String CUSTOMPARAM_URL="/customerParam?billerId=";
|
||||
public static final String BILL_FETCH_INTI="/couapp/bills/fetch";
|
||||
public static final String BILL_FETCH_BY_ID="/couapp/bills/fetch/byId?billId=";
|
||||
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 CUSTOMER_PARAM_GROUP = "/customerParamGroup?billerId=";
|
||||
public static final String AMOUNT_OPTIONS = "/amountOptions?billerId=";
|
||||
public static final String PLAN_CATEGORIES = "/planCategories?billerId=";
|
||||
public static final String INITIATING_CHANNEL = "/initiatingChannel";
|
||||
|
||||
public static final String BILLER_VALIDATE_URL = "/couapp/bills/validate";
|
||||
public static final String BILL_ID_URL = "/couapp/bills/validate/byId?billId=";
|
||||
|
||||
public static final String BILLER_DATA_FETCH_URL = "/billersById?billerId=";
|
||||
public static final String CUSTOMPARAM_URL = "/customerParam?billerId=";
|
||||
public static final String BILL_FETCH_INTI = "/couapp/bills/fetch";
|
||||
public static final String BILL_FETCH_BY_ID = "/couapp/bills/fetch/byId?billId=";
|
||||
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";
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ spring.application.name=bbps
|
||||
|
||||
|
||||
# Server port
|
||||
server.port=9090
|
||||
server.port=8080
|
||||
|
||||
# JPA & Hibernate
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
@@ -11,9 +11,9 @@ spring.jpa.properties.hibernate.default_schema=public
|
||||
|
||||
|
||||
# DataSource
|
||||
spring.datasource.url=jdbc:postgresql://localhost:5432/BBPS
|
||||
spring.datasource.url=jdbc:postgresql://localhost:5432/TestingDB
|
||||
spring.datasource.username=postgres
|
||||
spring.datasource.password=thakur@123
|
||||
spring.datasource.password=UAT@DB_2025
|
||||
spring.datasource.driver-class-name=org.postgresql.Driver
|
||||
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
|
||||
|
||||
|
||||
Reference in New Issue
Block a user