save billerdata to in database working code
This commit is contained in:
@@ -57,6 +57,13 @@ public class MasterDataController {
|
|||||||
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** 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)
|
@PostMapping(value = "/getCustomerParamDetails", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
public ResponseEntity<ResponseModel> getBillerDetails(
|
public ResponseEntity<ResponseModel> getBillerDetails(
|
||||||
@@ -70,5 +77,6 @@ public class MasterDataController {
|
|||||||
public ResponseModel fetchMasterData(@Validated @RequestBody MasterRequest masterRequest) {
|
public ResponseModel fetchMasterData(@Validated @RequestBody MasterRequest masterRequest) {
|
||||||
return masterDataService.getMasterData(masterRequest);
|
return masterDataService.getMasterData(masterRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
package com.billpaymentservice.bbps.dto;
|
package com.billpaymentservice.bbps.dto;
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -10,13 +11,12 @@ public class AgentFundTransfer {
|
|||||||
@NotBlank private String fundTxnReferenceId;
|
@NotBlank private String fundTxnReferenceId;
|
||||||
@NotBlank private String fundTxnRemarks;
|
@NotBlank private String fundTxnRemarks;
|
||||||
@NotBlank private String fundTxnDate;
|
@NotBlank private String fundTxnDate;
|
||||||
|
|
||||||
@NotNull private Double fundTxnAmt;
|
@NotNull private Double fundTxnAmt;
|
||||||
|
|
||||||
@NotBlank private String fundUTR;
|
@NotBlank private String fundUTR;
|
||||||
|
|
||||||
private String fundRespRemarks;
|
private String fundRespRemarks;
|
||||||
private String agentNpciId;
|
private String agentNpciId;
|
||||||
private String txnRefId;
|
private String txnRefId;
|
||||||
|
private String tenantId;
|
||||||
@NotBlank private String fundStatus; // FUND_TRANSFER_SUCCESS or FUND_TRANSFER_FAILED
|
@NotBlank private String fundStatus; // FUND_TRANSFER_SUCCESS or FUND_TRANSFER_FAILED
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ import lombok.Setter;
|
|||||||
@Setter
|
@Setter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class CustomParam {
|
public class CustomParamDTO {
|
||||||
private String customParamName;
|
private String customParamName;
|
||||||
private String dataType;
|
private String dataType;
|
||||||
private boolean optional;
|
private boolean optional;
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.billpaymentservice.bbps.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class DeviceBlockTag {
|
||||||
|
private String name;
|
||||||
|
private String tagId;
|
||||||
|
private String value;
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.billpaymentservice.bbps.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
|
||||||
|
public class DispositionsDTO {
|
||||||
|
private String dispositionId;
|
||||||
|
private String dispositionDescr;
|
||||||
|
private String tenantId;
|
||||||
|
}
|
||||||
@@ -4,11 +4,13 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
|
@ToString
|
||||||
public class GeneralResp {
|
public class GeneralResp {
|
||||||
private String statusCode;
|
private String statusCode;
|
||||||
private String status;
|
private String status;
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
package com.billpaymentservice.bbps.dto;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
public class TransactionDAO {
|
|
||||||
|
|
||||||
@NotBlank private String txnId;
|
|
||||||
@NotBlank private String refId;
|
|
||||||
|
|
||||||
private String txnNpciId;
|
|
||||||
|
|
||||||
@NotBlank private String orderId;
|
|
||||||
@NotBlank private String billId;
|
|
||||||
@NotBlank private String userType;
|
|
||||||
@NotBlank private String userId;
|
|
||||||
|
|
||||||
@NotNull private Double txnAmount;
|
|
||||||
@NotNull private Double totalTxnAmount;
|
|
||||||
|
|
||||||
@NotBlank private String billerId;
|
|
||||||
@NotBlank private String billerCategory;
|
|
||||||
@NotBlank private String billerName;
|
|
||||||
|
|
||||||
private String clientReqId;
|
|
||||||
private String offUsPay;
|
|
||||||
private String splitPay;
|
|
||||||
private String quickPay;
|
|
||||||
private String paymentMode;
|
|
||||||
|
|
||||||
private Double custConvFee;
|
|
||||||
private String currency;
|
|
||||||
private String status;
|
|
||||||
private String requestedIp;
|
|
||||||
private String customerMobNo;
|
|
||||||
private String macAddress;
|
|
||||||
|
|
||||||
private Double splitPayAmount;
|
|
||||||
private Double couCustConvFee;
|
|
||||||
|
|
||||||
private Boolean settlementVerification;
|
|
||||||
private String fundTxnType;
|
|
||||||
private String reason;
|
|
||||||
|
|
||||||
private List<String> amountTags;
|
|
||||||
private List<String> customerParamsDAOS;
|
|
||||||
private List<String> paymentInformation;
|
|
||||||
|
|
||||||
private List<CustomerParamDAO> customerParamsDAO;
|
|
||||||
|
|
||||||
private String planId;
|
|
||||||
private String planType;
|
|
||||||
|
|
||||||
private LocalDateTime creationDate;
|
|
||||||
private LocalDateTime modifiedDate;
|
|
||||||
|
|
||||||
private Long createdEpochDate;
|
|
||||||
private Long modifiedEpochDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package com.billpaymentservice.bbps.dto;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
|
||||||
|
public class TransactionDTO {
|
||||||
|
|
||||||
|
@NotBlank private String txnId;
|
||||||
|
@NotBlank private String refId;
|
||||||
|
private String txnNpciId;
|
||||||
|
private String paymentRefId;
|
||||||
|
private String remitterName;
|
||||||
|
|
||||||
|
|
||||||
|
@NotBlank private String orderId;
|
||||||
|
@NotBlank private String billId;
|
||||||
|
@NotBlank private String userType;
|
||||||
|
@NotBlank private String userId;
|
||||||
|
|
||||||
|
@NotNull private Double txnAmount;
|
||||||
|
@NotNull private Double totalTxnAmount;
|
||||||
|
|
||||||
|
@NotBlank private String billerId;
|
||||||
|
@NotBlank private String billerCategory;
|
||||||
|
@NotBlank private String billerName;
|
||||||
|
|
||||||
|
private String clientReqId;
|
||||||
|
private String offUsPay;
|
||||||
|
private String splitPay;
|
||||||
|
private String quickPay;
|
||||||
|
private String paymentMode;
|
||||||
|
private String agentPaymentInformation;
|
||||||
|
|
||||||
|
private Double custConvFee;
|
||||||
|
private String currency;
|
||||||
|
private String status;
|
||||||
|
private String requestedIp;
|
||||||
|
private String customerMobNo;
|
||||||
|
private String macAddress;
|
||||||
|
|
||||||
|
private Double splitPayAmount;
|
||||||
|
private Double couCustConvFee;
|
||||||
|
|
||||||
|
private Boolean settlementVerification;
|
||||||
|
private String fundTxnType;
|
||||||
|
private String reason;
|
||||||
|
|
||||||
|
private List<String> amountTags;
|
||||||
|
private List<String> customerParamsDAOS;
|
||||||
|
private List<String> paymentInformation;
|
||||||
|
private List<DeviceBlockTag> deviceBlockTags;
|
||||||
|
|
||||||
|
|
||||||
|
private List<CustomerParamDAO> customerParamsDAO;
|
||||||
|
|
||||||
|
private String planId;
|
||||||
|
private String planType;
|
||||||
|
|
||||||
|
// ✅ Date fields as String (for JSON compatibility)
|
||||||
|
private String creationDate;
|
||||||
|
private String modifiedDate;
|
||||||
|
|
||||||
|
private Long createdEpochDate;
|
||||||
|
private Long modifiedEpochDate;
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.billpaymentservice.bbps.dto.request;
|
||||||
|
|
||||||
|
public class DispositionRequest extends BaseClass {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,9 +3,11 @@ package com.billpaymentservice.bbps.dto.response;
|
|||||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
|
@ToString
|
||||||
public class BillPaymentResponse {
|
public class BillPaymentResponse {
|
||||||
|
|
||||||
private String txnId;
|
private String txnId;
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
package com.billpaymentservice.bbps.dto.response;
|
package com.billpaymentservice.bbps.dto.response;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.billpaymentservice.bbps.dto.ContactMaster;
|
import com.billpaymentservice.bbps.dto.ContactMaster;
|
||||||
import com.billpaymentservice.bbps.dto.CustomParam;
|
import com.billpaymentservice.bbps.dto.CustomParamDTO;
|
||||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||||
import com.billpaymentservice.bbps.entites.CustomerParam;
|
import com.billpaymentservice.bbps.entites.CustomerParam;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
@@ -20,5 +19,5 @@ import lombok.Setter;
|
|||||||
public class CustomParamResp {
|
public class CustomParamResp {
|
||||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||||
private GeneralResp generalResp;
|
private GeneralResp generalResp;
|
||||||
private List<CustomParam> customParamResp;
|
private List<CustomParamDTO> customParamResp;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.billpaymentservice.bbps.dto.response;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.billpaymentservice.bbps.dto.DispositionsDTO;
|
||||||
|
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
|
public class DispositionResponse {
|
||||||
|
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||||
|
private GeneralResp generalResp;
|
||||||
|
List<DispositionsDTO> dispositionsList;
|
||||||
|
}
|
||||||
+2
-2
@@ -2,7 +2,7 @@ package com.billpaymentservice.bbps.dto.response;
|
|||||||
|
|
||||||
import com.billpaymentservice.bbps.dto.AgentFundTransfer;
|
import com.billpaymentservice.bbps.dto.AgentFundTransfer;
|
||||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||||
import com.billpaymentservice.bbps.dto.TransactionDAO;
|
import com.billpaymentservice.bbps.dto.TransactionDTO;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -13,7 +13,7 @@ import lombok.Setter;
|
|||||||
public class TransactionStatusResponse {
|
public class TransactionStatusResponse {
|
||||||
|
|
||||||
@JsonProperty("transactionDAO")
|
@JsonProperty("transactionDAO")
|
||||||
private TransactionDAO transactionDAO;
|
private TransactionDTO transactionDAO;
|
||||||
|
|
||||||
@JsonProperty("agentFundTransfer")
|
@JsonProperty("agentFundTransfer")
|
||||||
private AgentFundTransfer agentFundTransfer;
|
private AgentFundTransfer agentFundTransfer;
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ import jakarta.persistence.*;
|
|||||||
import jakarta.validation.constraints.*;
|
import jakarta.validation.constraints.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@Entity
|
@Entity
|
||||||
|
@ToString
|
||||||
@Table(name = "additional_info")
|
@Table(name = "additional_info")
|
||||||
public class AdditionalInfo {
|
public class AdditionalInfo {
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
package com.billpaymentservice.bbps.entites;
|
package com.billpaymentservice.bbps.entites;
|
||||||
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.billpaymentservice.bbps.entites.BillerResponseParams;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "amount_option")
|
@Table(name = "amount_option")
|
||||||
@@ -15,9 +13,9 @@ import com.billpaymentservice.bbps.entites.BillerResponseParams;
|
|||||||
public class AmountOption {
|
public class AmountOption {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
||||||
@Column(name = "amount_option_id")
|
@Column(name = "amount_option_id")
|
||||||
private Long id;
|
@JsonProperty("amountOptionId") // ✅ JSON field map karo
|
||||||
|
private String amountOptionId; // ✅ String type, manual ID
|
||||||
|
|
||||||
@ElementCollection
|
@ElementCollection
|
||||||
@CollectionTable(
|
@CollectionTable(
|
||||||
@@ -31,4 +29,4 @@ public class AmountOption {
|
|||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "biller_response_id", nullable = false)
|
@JoinColumn(name = "biller_response_id", nullable = false)
|
||||||
private BillerResponseParams billerResponseParams;
|
private BillerResponseParams billerResponseParams;
|
||||||
}
|
}
|
||||||
@@ -147,8 +147,10 @@ public class BillerDetails {
|
|||||||
@OneToMany(mappedBy = "biller", cascade = CascadeType.ALL, orphanRemoval = true)
|
@OneToMany(mappedBy = "biller", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||||
private List<AdditionalInfo> billerAdditionalInfos;
|
private List<AdditionalInfo> billerAdditionalInfos;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "biller", cascade = CascadeType.ALL, orphanRemoval = true)
|
/*
|
||||||
private List<AdditionalInfo> billerAdditionalInfoPayments;
|
* @OneToMany(mappedBy = "biller", cascade = CascadeType.ALL, orphanRemoval =
|
||||||
|
* true) private List<AdditionalInfo> billerAdditionalInfoPayments;
|
||||||
|
*/
|
||||||
|
|
||||||
@OneToMany(mappedBy = "biller", cascade = CascadeType.ALL, orphanRemoval = true)
|
@OneToMany(mappedBy = "biller", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||||
private List<InterchangeFeeConf> interchangeFeeConves;
|
private List<InterchangeFeeConf> interchangeFeeConves;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import jakarta.validation.constraints.*;
|
import jakarta.validation.constraints.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -14,6 +14,7 @@ import java.util.List;
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@Entity
|
@Entity
|
||||||
|
@ToString
|
||||||
@Table(name = "biller_plan_response_params")
|
@Table(name = "biller_plan_response_params")
|
||||||
public class BillerPlanResponseParams {
|
public class BillerPlanResponseParams {
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.billpaymentservice.bbps.entites;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Entity
|
||||||
|
@Table(name = "custom_param")
|
||||||
|
public class CustomParam {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Column(name = "custom_param_name")
|
||||||
|
private String customParamName;
|
||||||
|
|
||||||
|
@Column(name = "data_type")
|
||||||
|
private String dataType;
|
||||||
|
|
||||||
|
@Column(name = "optional")
|
||||||
|
private Boolean optional;
|
||||||
|
|
||||||
|
@Column(name = "min_length")
|
||||||
|
private Integer minLength;
|
||||||
|
|
||||||
|
@Column(name = "max_length")
|
||||||
|
private Integer maxLength;
|
||||||
|
|
||||||
|
@Column(name = "regex")
|
||||||
|
private String regex;
|
||||||
|
|
||||||
|
@Column(name = "visibility")
|
||||||
|
private Boolean visibility;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,12 +3,14 @@ package com.billpaymentservice.bbps.entites;
|
|||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@Entity
|
@Entity
|
||||||
|
@ToString
|
||||||
@Table(name = "customer_param_groups")
|
@Table(name = "customer_param_groups")
|
||||||
public class CustomerParamGroups {
|
public class CustomerParamGroups {
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.billpaymentservice.bbps.entites;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Entity
|
||||||
|
@Table(name = "disposition_details")
|
||||||
|
@ToString
|
||||||
|
public class DispositionDetails {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Column(name = "disposition_id", nullable = false, unique = true)
|
||||||
|
private String dispositionId; // UUID type string
|
||||||
|
|
||||||
|
@Column(name = "disposition_descr", nullable = false)
|
||||||
|
private String dispositionDescr;
|
||||||
|
|
||||||
|
@Column(name = "tenant_id")
|
||||||
|
private String tenantId;
|
||||||
|
}
|
||||||
@@ -4,8 +4,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import jakarta.validation.constraints.*;
|
import jakarta.validation.constraints.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -15,6 +14,7 @@ import java.util.List;
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@Entity
|
@Entity
|
||||||
|
@ToString
|
||||||
@Table(name = "interchange_fee")
|
@Table(name = "interchange_fee")
|
||||||
public class InterchangeFee {
|
public class InterchangeFee {
|
||||||
|
|
||||||
|
|||||||
@@ -4,18 +4,20 @@ import jakarta.persistence.*;
|
|||||||
import jakarta.validation.constraints.*;
|
import jakarta.validation.constraints.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@Entity
|
@Entity
|
||||||
|
@ToString
|
||||||
@Table(name = "payment_channel")
|
@Table(name = "payment_channel")
|
||||||
public class PaymentChannel {
|
public class PaymentChannel {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "payment_channel_limit_id")
|
@Column(name = "payment_channel_limit_id")
|
||||||
@JsonProperty("paymentChannelLimitId") // 👈 Map JSON field to this property
|
private String paymentChannelLimitId; // Primary key (manual, not auto-generated)
|
||||||
private String id; // Primary key (manual, not auto-generated)
|
|
||||||
|
|
||||||
@NotBlank(message = "Payment channel is required")
|
@NotBlank(message = "Payment channel is required")
|
||||||
@Column(name = "payment_channel", nullable = false)
|
@Column(name = "payment_channel", nullable = false)
|
||||||
|
|||||||
@@ -2,15 +2,27 @@ package com.billpaymentservice.bbps.entites;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.validation.constraints.*;
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.FetchType;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.Pattern;
|
||||||
|
import jakarta.validation.constraints.PositiveOrZero;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "biller_payment_modes")
|
@Table(name = "biller_payment_modes")
|
||||||
|
@ToString
|
||||||
public class PaymentMode {
|
public class PaymentMode {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.billpaymentservice.bbps.repository;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
import com.billpaymentservice.bbps.entites.DispositionDetails;
|
||||||
|
|
||||||
|
public interface DispositionRepository extends JpaRepository<DispositionDetails,String> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -19,4 +19,6 @@ public interface MasterDataService {
|
|||||||
|
|
||||||
public ResponseModel getContactMaster(ContactMasterRequest contactMasterRequest);
|
public ResponseModel getContactMaster(ContactMasterRequest contactMasterRequest);
|
||||||
|
|
||||||
|
public ResponseModel getDispositionDetails();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,132 +49,145 @@ public class AgentServiceImpl implements AgentService {
|
|||||||
this.beneficiaryDetailsRepository=beneficiaryDetailsRepository;
|
this.beneficiaryDetailsRepository=beneficiaryDetailsRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseModel initiateBillFetch(FetchBillRequest fetchBillRequest) {
|
public ResponseModel initiateBillFetch(FetchBillRequest fetchBillRequest) {
|
||||||
String url = agentDtaUrl+BBPSConstant.BILL_FETCH_INTI;
|
String url = agentDtaUrl + BBPSConstant.BILL_FETCH_INTI;
|
||||||
System.out.println(url);
|
System.out.println(url);
|
||||||
|
|
||||||
BharatConnectMaster headersData=beneficiaryDetailsRepository.findByOrgId("ORG001");
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("x-digiledge-key",headersData.getXDigiledgeKey());
|
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||||
headers.set("agentId", headersData.getAgentId());
|
headers.set("agentId", headersData.getAgentId());
|
||||||
headers.set("tenantId", headersData.getTenantId());
|
headers.set("tenantId", headersData.getTenantId());
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
ResponseModel responseModel = new ResponseModel();
|
||||||
|
|
||||||
ResponseModel responseModel = new ResponseModel();
|
try {
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||||
|
|
||||||
try {
|
// ✅ 1st API Call
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
String json = objectMapper.writeValueAsString(fetchBillRequest);
|
||||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
Map<String, String> responseMap = httpService.postRequest(url, json, headers);
|
||||||
|
String responseData = responseMap.get("data");
|
||||||
|
|
||||||
// ✅ Convert request to JSON
|
log.info("📦 1st API Response: {}", responseData);
|
||||||
String json = objectMapper.writeValueAsString(fetchBillRequest);
|
|
||||||
|
|
||||||
// ✅ Call the API using httpService
|
if (responseData == null || responseData.isEmpty()) {
|
||||||
Map<String, String> responseMap = httpService.postRequest(url, json, headers);
|
throw new CustomException("Empty response from BBPS server");
|
||||||
String responseData = responseMap.get("data");
|
}
|
||||||
|
|
||||||
log.info("📦 Bill Fetch API Response: {}", responseData);
|
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
|
||||||
|
|
||||||
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
|
|
||||||
FetchBillResponse fetchBillResponse = objectMapper.convertValue(dataMap, FetchBillResponse.class);
|
|
||||||
GeneralResponse 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
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
if (!dataMap.containsKey("genericResponse")) {
|
||||||
|
throw new CustomException("Invalid response structure from BBPS");
|
||||||
|
}
|
||||||
|
|
||||||
// ✅ Build final ResponseModel
|
FetchBillResponse fetchBillResponse = objectMapper.convertValue(dataMap, FetchBillResponse.class);
|
||||||
responseModel = new ResponseModel(
|
|
||||||
generalResponse.getMessage(),
|
|
||||||
generalResponse.getStatus(),
|
|
||||||
Integer.parseInt(generalResponse.getStatusCode()),
|
|
||||||
fetchBillResponse
|
|
||||||
);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
// ✅ IMMEDIATE 2nd API CALL (SYNCHRONOUS)
|
||||||
log.error("❌ Exception in initiateBillFetch(): {}", e.getMessage(), e);
|
BillFetchByBillIdRequest pollReq = new BillFetchByBillIdRequest();
|
||||||
responseModel.setStatus("500");
|
pollReq.setBillId(fetchBillResponse.getBillId());
|
||||||
responseModel.setMessage("Exception occurred");
|
|
||||||
responseModel.setData(e.getMessage());
|
// ✅ This will wait for the response
|
||||||
}
|
ResponseModel secondApiResponse = fetchBillById(pollReq);
|
||||||
|
|
||||||
|
// ✅ Return directly the second API response
|
||||||
|
return secondApiResponse;
|
||||||
|
|
||||||
return responseModel;
|
} 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) {
|
||||||
|
|
||||||
@Override
|
String billId = billFetchByBillIdRequest.getBillId();
|
||||||
public ResponseModel fetchBillById(BillFetchByBillIdRequest billFetchByBillIdRequest) {
|
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + "1ced7566-1add-4e01-9ed6-04cd67ac9684";
|
||||||
|
// String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + billId;
|
||||||
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();
|
System.out.print(fullUrl);
|
||||||
|
|
||||||
try {
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
|
||||||
new TypeReference<Map<String, Object>>() {
|
|
||||||
});
|
|
||||||
if (!dataMap.containsKey("genericResponse")) {
|
|
||||||
throw new CustomException(String.valueOf(dataMap.get("message")), // message
|
|
||||||
String.valueOf(dataMap.get("status")), // status
|
|
||||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode (int)
|
|
||||||
String.valueOf(dataMap.get("remarks")) );
|
|
||||||
}
|
|
||||||
|
|
||||||
BillDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillDataResponse.class);
|
|
||||||
|
|
||||||
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
|
||||||
|
|
||||||
ResponseModel responseModel=new ResponseModel( generalResp.getMessage(),
|
|
||||||
generalResp.getStatus(),
|
|
||||||
Integer.parseInt(generalResp.getStatusCode()),
|
|
||||||
responseWrapper);
|
|
||||||
|
|
||||||
return responseModel;
|
|
||||||
|
|
||||||
} catch (JsonProcessingException e) {
|
HttpHeaders headers = new HttpHeaders();
|
||||||
log.error("Error parsing responseData JSON: {}", e.getMessage());
|
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||||
throw new CustomException("Invalid JSON received from API");
|
headers.set("agentId", headersData.getAgentId());
|
||||||
}
|
headers.set("tenantId", headersData.getTenantId());
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
|
int maxWaitTimeMs = 40000; // 40 seconds
|
||||||
|
int intervalMs = 6000; // 3 seconds
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||||
|
String responseData = responseMap.get("data");
|
||||||
|
log.info("data is :{}", responseData);
|
||||||
|
|
||||||
|
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")),
|
||||||
|
String.valueOf(dataMap.get("status")),
|
||||||
|
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||||
|
String.valueOf(dataMap.get("remarks"))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
BillDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillDataResponse.class);
|
||||||
|
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||||
|
|
||||||
|
String status = generalResp.getStatus();
|
||||||
|
|
||||||
|
// ✅ 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");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Thread.sleep(intervalMs);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
throw new CustomException("Thread interrupted during retry");
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("Bill still in progress... retrying after {} seconds", (intervalMs / 1000));
|
||||||
|
continue; // retry again
|
||||||
|
}
|
||||||
|
|
||||||
|
// ✅ 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
|
||||||
|
);
|
||||||
|
|
||||||
|
return responseModel;
|
||||||
|
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
log.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||||
|
throw new CustomException("Invalid JSON received from API");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,17 +5,16 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.modelmapper.ModelMapper;
|
import org.modelmapper.ModelMapper;
|
||||||
import org.modelmapper.convention.MatchingStrategies;
|
import org.modelmapper.convention.MatchingStrategies;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.billpaymentservice.bbps.dto.BillerDTO;
|
import com.billpaymentservice.bbps.dto.DispositionsDTO;
|
||||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||||
import com.billpaymentservice.bbps.dto.MasterApiResponse;
|
import com.billpaymentservice.bbps.dto.MasterApiResponse;
|
||||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||||
@@ -29,12 +28,19 @@ import com.billpaymentservice.bbps.dto.response.BillerResponse;
|
|||||||
import com.billpaymentservice.bbps.dto.response.CategoryResponse;
|
import com.billpaymentservice.bbps.dto.response.CategoryResponse;
|
||||||
import com.billpaymentservice.bbps.dto.response.ContactMasterResponse;
|
import com.billpaymentservice.bbps.dto.response.ContactMasterResponse;
|
||||||
import com.billpaymentservice.bbps.dto.response.CustomParamResp;
|
import com.billpaymentservice.bbps.dto.response.CustomParamResp;
|
||||||
|
import com.billpaymentservice.bbps.dto.response.DispositionResponse;
|
||||||
|
import com.billpaymentservice.bbps.entites.AmountOption;
|
||||||
import com.billpaymentservice.bbps.entites.BBPSMerchantValidation;
|
import com.billpaymentservice.bbps.entites.BBPSMerchantValidation;
|
||||||
import com.billpaymentservice.bbps.entites.BillPayment;
|
import com.billpaymentservice.bbps.entites.BillPayment;
|
||||||
import com.billpaymentservice.bbps.entites.BillerDetails;
|
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.AppException;
|
||||||
import com.billpaymentservice.bbps.exception.CustomException;
|
import com.billpaymentservice.bbps.exception.CustomException;
|
||||||
import com.billpaymentservice.bbps.repository.BillerDataRepository;
|
import com.billpaymentservice.bbps.repository.BillerDataRepository;
|
||||||
|
import com.billpaymentservice.bbps.repository.DispositionRepository;
|
||||||
import com.billpaymentservice.bbps.repository.MerchantRepository;
|
import com.billpaymentservice.bbps.repository.MerchantRepository;
|
||||||
import com.billpaymentservice.bbps.service.MasterDataService;
|
import com.billpaymentservice.bbps.service.MasterDataService;
|
||||||
import com.billpaymentservice.bbps.util.BBPSConstant;
|
import com.billpaymentservice.bbps.util.BBPSConstant;
|
||||||
@@ -55,6 +61,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
|
|
||||||
private MerchantRepository merchantRegisterRepo;
|
private MerchantRepository merchantRegisterRepo;
|
||||||
private HttpClientApi httpClientApi;
|
private HttpClientApi httpClientApi;
|
||||||
|
private final DispositionRepository dispositionRepository;
|
||||||
private Helper helper;
|
private Helper helper;
|
||||||
private final BillerDataRepository billerDataRespository;
|
private final BillerDataRepository billerDataRespository;
|
||||||
|
|
||||||
@@ -68,70 +75,109 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
HttpService httpService,
|
HttpService httpService,
|
||||||
HttpClientApi httpClientApi,
|
HttpClientApi httpClientApi,
|
||||||
Helper helper,
|
Helper helper,
|
||||||
BillerDataRepository billerDataRespository
|
BillerDataRepository billerDataRespository,
|
||||||
|
DispositionRepository dispositionRepository
|
||||||
) {
|
) {
|
||||||
this.merchantRegisterRepo = merchantRegisterRepo;
|
this.merchantRegisterRepo = merchantRegisterRepo;
|
||||||
this.httpService = httpService;
|
this.httpService = httpService;
|
||||||
this.httpClientApi = httpClientApi;
|
this.httpClientApi = httpClientApi;
|
||||||
this.helper = helper;
|
this.helper = helper;
|
||||||
this.billerDataRespository=billerDataRespository;
|
this.billerDataRespository=billerDataRespository;
|
||||||
|
this.dispositionRepository=dispositionRepository;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public ResponseModel getBillerByBillerId(BillerDetailRequest billerDetailRequest) {
|
public ResponseModel getBillerByBillerId(BillerDetailRequest billerDetailRequest) {
|
||||||
|
|
||||||
String billerId = billerDetailRequest.getBillerId();
|
String billerId = billerDetailRequest.getBillerId();
|
||||||
String fullUrl = masterRegisterUrl + BBPSConstant.BILLER_DATA_FETCH_URL+billerId;
|
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);
|
||||||
|
|
||||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
String responseData = responseMap.get("data");
|
|
||||||
log.info("data is :{}", responseData);
|
|
||||||
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
try {
|
||||||
|
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||||
|
new TypeReference<Map<String, Object>>() {
|
||||||
|
});
|
||||||
|
if (!dataMap.containsKey("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")) );
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
BillerDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillerDataResponse.class);
|
||||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||||
new TypeReference<Map<String, Object>>() {
|
ModelMapper mapper = new ModelMapper();
|
||||||
});
|
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||||
if (!dataMap.containsKey("generalResp")) {
|
BillerDetails entity = mapper.map(responseWrapper.getBillerDAO(), BillerDetails.class);
|
||||||
throw new CustomException(String.valueOf(dataMap.get("message")), // message
|
|
||||||
String.valueOf(dataMap.get("status")), // status
|
// Manually set parent reference
|
||||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode (int)
|
if (entity.getBillerPaymentModes() != null) {
|
||||||
String.valueOf(dataMap.get("remarks")) );
|
entity.getBillerPaymentModes().forEach(m -> m.setBiller(entity));
|
||||||
}
|
}
|
||||||
|
if (entity.getBillerPaymentChannels() != null) {
|
||||||
BillerDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillerDataResponse.class);
|
entity.getBillerPaymentChannels().forEach(c -> c.setBiller(entity));
|
||||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
}
|
||||||
ModelMapper mapper = new ModelMapper();
|
if (entity.getBillerCustomerParams() != null) {
|
||||||
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
entity.getBillerCustomerParams().forEach(p -> p.setBiller(entity));
|
||||||
BillerDetails entity = mapper.map(responseWrapper.getBillerDAO(), BillerDetails.class);
|
}
|
||||||
|
if (entity.getBillerAdditionalInfos() != null) {
|
||||||
|
entity.getBillerAdditionalInfos().forEach(a -> a.setBiller(entity));
|
||||||
|
}
|
||||||
|
if (entity.getInterchangeFees() != null) {
|
||||||
|
for (InterchangeFee fee : entity.getInterchangeFees()) {
|
||||||
|
fee.setBiller(entity); // link InterchangeFee → BillerDetails
|
||||||
|
|
||||||
|
if (fee.getInterchangeFeeDetails() != null) {
|
||||||
|
for (InterchangeFeeDetail detail : fee.getInterchangeFeeDetails()) {
|
||||||
|
detail.setInterchangeFee(fee); // link InterchangeFeeDetail → InterchangeFee
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
System.out.println(entity);
|
if (entity.getInterchangeFeeConves() != null) {
|
||||||
|
entity.getInterchangeFeeConves().forEach(fc -> fc.setBiller(entity));
|
||||||
if (entity != null)
|
}
|
||||||
{
|
|
||||||
billerDataRespository.save(entity);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LOGGER.warn("No biller found in response to save.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
// For OneToOne relationships
|
||||||
ResponseModel responseModel=new ResponseModel( generalResp.getMessage(),
|
if (entity.getCustomerParamGroups() != null)
|
||||||
generalResp.getStatus(),
|
entity.getCustomerParamGroups().setBiller(entity);
|
||||||
Integer.parseInt(generalResp.getStatusCode()),
|
|
||||||
responseWrapper);
|
|
||||||
|
|
||||||
return responseModel;
|
|
||||||
|
|
||||||
} catch (JsonProcessingException e) {
|
if (entity.getBillerPlanResponseParams() != null)
|
||||||
log.error("Error parsing responseData JSON: {}", e.getMessage());
|
entity.getBillerPlanResponseParams().setBiller(entity);
|
||||||
throw new CustomException("Invalid JSON received from API");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// 🔥🔥🔥 YEH MISSING CODE ADD KARO 🔥🔥🔥
|
||||||
|
if (entity.getBillerResponseParams() != null) {
|
||||||
|
BillerResponseParams responseParams = entity.getBillerResponseParams();
|
||||||
|
responseParams.setBiller(entity); // Parent reference
|
||||||
|
|
||||||
|
// 🔥 AMOUNT OPTIONS KE RELATIONSHIPS SET KARO
|
||||||
|
if (responseParams.getAmountOptions() != null) {
|
||||||
|
for (AmountOption option : responseParams.getAmountOptions()) {
|
||||||
|
option.setBillerResponseParams(responseParams); // YEH MISSING THA
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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
|
@Override
|
||||||
@@ -274,4 +320,55 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
|
|
||||||
return new ResponseModel();
|
return new ResponseModel();
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public ResponseModel getDispositionDetails() {
|
||||||
|
String fullUrl=masterRegisterUrl+BBPSConstant.DISPOSTION_URL;
|
||||||
|
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||||
|
String responseData = responseMap.get("data");
|
||||||
|
|
||||||
|
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")) );
|
||||||
|
}
|
||||||
|
|
||||||
|
DispositionResponse responseWrapper = objectMapper.convertValue(dataMap, DispositionResponse.class);
|
||||||
|
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());
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
return responseModel;
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
log.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||||
|
throw new CustomException("Invalid JSON received from API");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ public class PaymentServiceImpl implements PaymentService {
|
|||||||
|
|
||||||
// ✅ Convert to your custom DTO
|
// ✅ Convert to your custom DTO
|
||||||
BillPaymentResponse billPaymentResponse = objectMapper.convertValue(dataMap, BillPaymentResponse.class);
|
BillPaymentResponse billPaymentResponse = objectMapper.convertValue(dataMap, BillPaymentResponse.class);
|
||||||
|
System.out.print(billPaymentResponse);
|
||||||
GeneralResp generalResponse = billPaymentResponse.getGenericResponse();
|
GeneralResp generalResponse = billPaymentResponse.getGenericResponse();
|
||||||
//
|
//
|
||||||
// start a new thread here
|
// start a new thread here
|
||||||
@@ -109,15 +110,16 @@ public class PaymentServiceImpl implements PaymentService {
|
|||||||
* return fetchBillById(pollReq); }, 3, // interval in seconds 15 // total time
|
* return fetchBillById(pollReq); }, 3, // interval in seconds 15 // total time
|
||||||
* in seconds );
|
* in seconds );
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ModelMapper mapper = new ModelMapper();
|
ModelMapper mapper = new ModelMapper();
|
||||||
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||||
BillPayment entity = mapper.map(billPaymentResponse, BillPayment.class);
|
BillPayment entity = mapper.map(billPaymentResponse, BillPayment.class);
|
||||||
paymentRepository.save(entity);
|
paymentRepository.save(entity);
|
||||||
|
TransactionStatusRequest transactionStatusRequest=new TransactionStatusRequest();
|
||||||
// ✅ Build final ResponseModel
|
//call the checkTransactionStatus
|
||||||
responseModel = new ResponseModel(generalResponse.getMessage(), generalResponse.getStatus(),
|
transactionStatusRequest.setTxnId(billPaymentResponse.getTxnId());
|
||||||
Integer.parseInt(generalResponse.getStatusCode()), billPaymentResponse);
|
System.out.println(transactionStatusRequest);
|
||||||
|
responseModel= checkTrasactionStatus(transactionStatusRequest);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("❌ Exception in initiateBillFetch(): {}", e.getMessage(), e);
|
LOGGER.error("❌ Exception in initiateBillFetch(): {}", e.getMessage(), e);
|
||||||
responseModel.setStatus("500");
|
responseModel.setStatus("500");
|
||||||
@@ -131,49 +133,88 @@ public class PaymentServiceImpl implements PaymentService {
|
|||||||
@Override
|
@Override
|
||||||
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest) {
|
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest) {
|
||||||
|
|
||||||
String url=paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL+transactionStatusRequest.getTxnId();
|
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
|
||||||
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
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(url,headers);
|
|
||||||
String responseData = responseMap.get("data");
|
|
||||||
LOGGER.info("data is :{}", responseData);
|
|
||||||
|
|
||||||
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
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);
|
||||||
|
|
||||||
try {
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
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")) );
|
|
||||||
}
|
|
||||||
|
|
||||||
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
|
|
||||||
|
|
||||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
|
||||||
|
|
||||||
ResponseModel responseModel=new ResponseModel( generalResp.getMessage(),
|
|
||||||
generalResp.getStatus(),
|
|
||||||
Integer.parseInt(generalResp.getStatusCode()),
|
|
||||||
responseWrapper);
|
|
||||||
|
|
||||||
return responseModel;
|
|
||||||
|
|
||||||
} catch (JsonProcessingException e) {
|
// ✅ Polling configuration
|
||||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
long startTime = System.currentTimeMillis();
|
||||||
throw new CustomException("Invalid JSON received from API");
|
long maxWaitTimeMs = 40000; // 40 seconds timeout
|
||||||
}
|
long intervalMs = 5000; // retry every 5 seconds
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||||
|
String responseData = responseMap.get("data");
|
||||||
|
LOGGER.info("Transaction status response data: {}", responseData);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
|
||||||
|
|
||||||
|
// If genericResponse key missing, throw exception
|
||||||
|
if (!dataMap.containsKey("generalResp")) {
|
||||||
|
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"))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Convert into proper DTO
|
||||||
|
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
|
||||||
|
|
||||||
|
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||||
|
|
||||||
|
String status = generalResp.getStatus();
|
||||||
|
LOGGER.info("Current transaction status: {}", status);
|
||||||
|
|
||||||
|
// ✅ If IN_PROGRESS → wait & retry
|
||||||
|
if ("INPROGRESS".equalsIgnoreCase(status)) {
|
||||||
|
|
||||||
|
if (System.currentTimeMillis() - startTime > maxWaitTimeMs) {
|
||||||
|
// Timeout after 40 sec
|
||||||
|
throw new CustomException(
|
||||||
|
"Timeout waiting for transaction completion",
|
||||||
|
"FAILED",
|
||||||
|
408,
|
||||||
|
"Transaction still in progress after 40 seconds"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Thread.sleep(intervalMs);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
throw new CustomException("Thread interrupted during retry");
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGGER.info("Transaction still IN_PROGRESS... retrying after {} seconds", (intervalMs / 1000));
|
||||||
|
continue; // retry
|
||||||
|
}
|
||||||
|
|
||||||
|
// ✅ If status is SUCCESS / FAILED / etc. → return response
|
||||||
|
ResponseModel responseModel = new ResponseModel(
|
||||||
|
generalResp.getMessage(),
|
||||||
|
generalResp.getStatus(),
|
||||||
|
Integer.parseInt(generalResp.getStatusCode()),
|
||||||
|
responseWrapper
|
||||||
|
);
|
||||||
|
|
||||||
|
return responseModel;
|
||||||
|
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||||
|
throw new CustomException("Invalid JSON received from API");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -32,5 +32,6 @@ public class BBPSConstant {
|
|||||||
public static final String BILL_FETCH_BY_ID="/couapp/bills/fetch/byId?billId=";
|
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 PAYMENT_URL="/agent/bills/payment";
|
||||||
public static final String CHECK_TRANSACTION_URL="/transactions/payment/byTxnId?txnId=";
|
public static final String CHECK_TRANSACTION_URL="/transactions/payment/byTxnId?txnId=";
|
||||||
|
public static final String DISPOSTION_URL="/disposition";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ server.port=9090
|
|||||||
# JPA & Hibernate
|
# JPA & Hibernate
|
||||||
spring.jpa.hibernate.ddl-auto=update
|
spring.jpa.hibernate.ddl-auto=update
|
||||||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
|
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
|
||||||
|
spring.jpa.properties.hibernate.default_schema=public
|
||||||
|
|
||||||
|
|
||||||
# DataSource
|
# DataSource
|
||||||
spring.datasource.url=jdbc:postgresql://localhost:5432/BBPS
|
spring.datasource.url=jdbc:postgresql://localhost:5432/BBPS
|
||||||
|
|||||||
Reference in New Issue
Block a user