update code resolved conflict
This commit is contained in:
@@ -11,6 +11,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||||
import com.billpaymentservice.bbps.dto.request.BillFetchByBillIdRequest;
|
import com.billpaymentservice.bbps.dto.request.BillFetchByBillIdRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.request.BillFetchByClientIdRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.request.BillValidateByClientIdRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.FetchBillRequest;
|
import com.billpaymentservice.bbps.dto.request.FetchBillRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.FetchBillValidatestRequest;
|
import com.billpaymentservice.bbps.dto.request.FetchBillValidatestRequest;
|
||||||
import com.billpaymentservice.bbps.service.AgentService;
|
import com.billpaymentservice.bbps.service.AgentService;
|
||||||
@@ -69,4 +71,20 @@ public class AgentController {
|
|||||||
return ResponseEntity.ok(response);
|
return ResponseEntity.ok(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/fetchBillByClientReqId", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
public ResponseEntity<ResponseModel> fetchBillByClientReqId(
|
||||||
|
@Validated @RequestBody BillFetchByClientIdRequest billFetchByClientIdRequest) {
|
||||||
|
|
||||||
|
ResponseModel response = agentService.fetchBillByClientReqId(billFetchByClientIdRequest);
|
||||||
|
return ResponseEntity.ok(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/fetchBillValidateByClientReqId", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
public ResponseEntity<ResponseModel> fetchBillValidateByClientReqId(
|
||||||
|
@Validated @RequestBody BillValidateByClientIdRequest billValidateByClientIdRequest) {
|
||||||
|
|
||||||
|
ResponseModel response = agentService.fetchBillValidateByClientReqId(billValidateByClientIdRequest);
|
||||||
|
return ResponseEntity.ok(response);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import com.billpaymentservice.bbps.dto.request.AllMasterOptionsRequest;
|
|||||||
import com.billpaymentservice.bbps.dto.request.ComplainStatusRequest;
|
import com.billpaymentservice.bbps.dto.request.ComplainStatusRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.ComplaintRequestDTO;
|
import com.billpaymentservice.bbps.dto.request.ComplaintRequestDTO;
|
||||||
import com.billpaymentservice.bbps.dto.request.GetTicketLatestStausRequest;
|
import com.billpaymentservice.bbps.dto.request.GetTicketLatestStausRequest;
|
||||||
|
|
||||||
|
import com.billpaymentservice.bbps.dto.request.ViewAllComplaintsRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.ViewAllComplaintsTicketsRequest;
|
import com.billpaymentservice.bbps.dto.request.ViewAllComplaintsTicketsRequest;
|
||||||
import com.billpaymentservice.bbps.service.ComplainService;
|
import com.billpaymentservice.bbps.service.ComplainService;
|
||||||
|
|
||||||
@@ -42,7 +44,8 @@ public class ComplainController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/checkTicketStatus", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
@PostMapping(value = "/checkTicketStatus", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
public ResponseEntity<ResponseModel> getComplaintStatus(@Validated @RequestBody GetTicketLatestStausRequest request) {
|
public ResponseEntity<ResponseModel> getComplaintStatus(
|
||||||
|
@Validated @RequestBody GetTicketLatestStausRequest request) {
|
||||||
log.info("Received complaint status request for complaintId: {}", request.getTicketId());
|
log.info("Received complaint status request for complaintId: {}", request.getTicketId());
|
||||||
ResponseModel response = complainService.getComplaintStatus(request);
|
ResponseModel response = complainService.getComplaintStatus(request);
|
||||||
return ResponseEntity.ok(response);
|
return ResponseEntity.ok(response);
|
||||||
@@ -64,7 +67,7 @@ public class ComplainController {
|
|||||||
|
|
||||||
@PostMapping("/allMasterOptions")
|
@PostMapping("/allMasterOptions")
|
||||||
public ResponseEntity<ResponseModel> getAllStatuses(@Validated @RequestBody AllMasterOptionsRequest request) {
|
public ResponseEntity<ResponseModel> getAllStatuses(@Validated @RequestBody AllMasterOptionsRequest request) {
|
||||||
return ResponseEntity.ok(complainService.getAllActiveStatuses(request));
|
return ResponseEntity.ok(complainService.getAllActiveStatuses(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/viewAllComplaints")
|
@PostMapping("/viewAllComplaints")
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||||
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
|
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.TransactionStatusRequest;
|
import com.billpaymentservice.bbps.dto.request.TransactionStatusRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.request.TrasactionStatusByClientReqIdRequest;
|
||||||
import com.billpaymentservice.bbps.service.PaymentService;
|
import com.billpaymentservice.bbps.service.PaymentService;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@@ -43,6 +44,12 @@ public class PaymentController {
|
|||||||
return ResponseEntity.ok(response);
|
return ResponseEntity.ok(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/checkTransactionStatusByClientReqId", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
public ResponseEntity<ResponseModel> checkTransactionStatusByClientReqId(
|
||||||
|
@Validated @RequestBody TrasactionStatusByClientReqIdRequest transactionStatusRequest) {
|
||||||
|
|
||||||
|
ResponseModel response = paymentService.checkTrasactionStatusByClientReqId(transactionStatusRequest);
|
||||||
|
return ResponseEntity.ok(response);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,14 @@ package com.billpaymentservice.bbps.dto;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public class ComplainDetailsDto {
|
public class ComplainDetailsDto {
|
||||||
|
|
||||||
@JsonProperty("TicketId")
|
@JsonProperty("TicketId")
|
||||||
|
|||||||
@@ -20,49 +20,35 @@ import lombok.ToString;
|
|||||||
public abstract class BaseClass {
|
public abstract class BaseClass {
|
||||||
|
|
||||||
|
|
||||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
|
||||||
@NotBlank(message = "MID cannot be null or blank")
|
@NotBlank(message = "MID cannot be null or blank")
|
||||||
private String mid;
|
private String mid;
|
||||||
|
|
||||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
|
||||||
|
|
||||||
@NotBlank(message = "Secret key cannot be null or blank")
|
@NotBlank(message = "Secret key cannot be null or blank")
|
||||||
private String secretKey;
|
private String secretKey;
|
||||||
|
|
||||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
|
||||||
@NotBlank(message = "Request ID cannot be null or blank")
|
@NotBlank(message = "Request ID cannot be null or blank")
|
||||||
private String reqId;
|
private String reqId;
|
||||||
|
|
||||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
|
||||||
private DeviceDetail deviceDetial;
|
private DeviceDetail deviceDetial;
|
||||||
// ✅ 10 User Defined Fields (UDF1–UDF10)
|
// ✅ 10 User Defined Fields (UDF1–UDF10)
|
||||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
|
||||||
private String udf1;
|
private String udf1;
|
||||||
|
|
||||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
|
||||||
private String udf2;
|
private String udf2;
|
||||||
|
|
||||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
|
||||||
private String udf3;
|
private String udf3;
|
||||||
|
|
||||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
|
||||||
private String udf4;
|
private String udf4;
|
||||||
|
|
||||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
|
||||||
private String udf5;
|
private String udf5;
|
||||||
|
|
||||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
|
||||||
private String udf6;
|
private String udf6;
|
||||||
|
|
||||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
|
||||||
private String udf7;
|
private String udf7;
|
||||||
|
|
||||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
|
||||||
private String udf8;
|
private String udf8;
|
||||||
|
|
||||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
|
||||||
private String udf9;
|
private String udf9;
|
||||||
|
|
||||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
|
||||||
private String udf10;
|
private String udf10;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.billpaymentservice.bbps.dto.request;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class BillFetchByClientIdRequest extends BaseClass{
|
||||||
|
|
||||||
|
private String clientReqId;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -21,6 +21,7 @@ public class BillPaymentRequest extends BaseClass {
|
|||||||
private String customerMobNo;
|
private String customerMobNo;
|
||||||
private Integer txnAmount;
|
private Integer txnAmount;
|
||||||
private String paymentRefId;
|
private String paymentRefId;
|
||||||
|
private String clientReqId;
|
||||||
private String paymentChannel;
|
private String paymentChannel;
|
||||||
|
|
||||||
private List<DeviceBlockTagRequest> deviceBlockTags;
|
private List<DeviceBlockTagRequest> deviceBlockTags;
|
||||||
|
|||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
package com.billpaymentservice.bbps.dto.request;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class BillValidateByClientIdRequest extends BaseClass{
|
||||||
|
|
||||||
|
private String clientReqId;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -22,6 +22,7 @@ public class FetchBillValidatestRequest extends BaseClass {
|
|||||||
private String billerCategory; // String, CategoryResponseList of the biller
|
private String billerCategory; // String, CategoryResponseList of the biller
|
||||||
@NotNull
|
@NotNull
|
||||||
private String customerMobNo; // String, Mobile of the Customer
|
private String customerMobNo; // String, Mobile of the Customer
|
||||||
|
private String clientReqId;
|
||||||
|
|
||||||
// Optional Fields
|
// Optional Fields
|
||||||
private String macAddress; // Alphanumeric MAC Address of the Agent Server
|
private String macAddress; // Alphanumeric MAC Address of the Agent Server
|
||||||
|
|||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
package com.billpaymentservice.bbps.dto.request;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class TrasactionStatusByClientReqIdRequest extends BaseClass{
|
||||||
|
|
||||||
|
private String clientReqId;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.billpaymentservice.bbps.dto.request;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class ViewAllComplaintsRequest extends BaseClass{
|
||||||
|
|
||||||
|
private String statusType; // e.g. COMPLAINT_OPEN_SUCCESS
|
||||||
|
private Integer pageNo; // default 0
|
||||||
|
private Integer pageSize; // default 10
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.billpaymentservice.bbps.dto.response;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.billpaymentservice.bbps.dto.ComplainDetailsDto;
|
||||||
|
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public class ViewAllComplaintsResponse {
|
||||||
|
private List<ComplainDetailsDto> complaintsList;
|
||||||
|
private GeneralResp generalResp;
|
||||||
|
private Integer pageNo;
|
||||||
|
private Integer pageSize;
|
||||||
|
private Integer totalPages;
|
||||||
|
private Long totalElements;
|
||||||
|
}
|
||||||
@@ -5,12 +5,14 @@ import java.util.List;
|
|||||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||||
import com.billpaymentservice.bbps.dto.ViewComplaintDTO;
|
import com.billpaymentservice.bbps.dto.ViewComplaintDTO;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public class ViewComplainByIdResponse {
|
public class ViewComplainByIdResponse {
|
||||||
private List<ViewComplaintDTO> tickets;
|
private List<ViewComplaintDTO> tickets;
|
||||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||||
|
|||||||
+41
@@ -0,0 +1,41 @@
|
|||||||
|
package com.billpaymentservice.bbps.dto.sentRequest;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.billpaymentservice.bbps.dto.request.AmountBreakRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.request.CustomerParamTagRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.request.DeviceBlockTagRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.request.RemitterIdentityRequest;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class BillPaymentForwardRequest {
|
||||||
|
|
||||||
|
private String tenantId;
|
||||||
|
private String refId;
|
||||||
|
private String billId;
|
||||||
|
private boolean amountOptions;
|
||||||
|
private String paymentMode;
|
||||||
|
private String paymentInformation;
|
||||||
|
private String billerId;
|
||||||
|
private String billerName;
|
||||||
|
private String billerCategory;
|
||||||
|
private String macAdress;
|
||||||
|
private String customerMobNo;
|
||||||
|
private Integer txnAmount;
|
||||||
|
private String paymentRefId;
|
||||||
|
private String clientReqId;
|
||||||
|
private String paymentChannel;
|
||||||
|
|
||||||
|
private List<DeviceBlockTagRequest> deviceBlockTags;
|
||||||
|
private List<CustomerParamTagRequest> customerParamsRequest;
|
||||||
|
private List<RemitterIdentityRequest> remitterIdentity;
|
||||||
|
private List<AmountBreakRequest> amountBreakSet;
|
||||||
|
}
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
package com.billpaymentservice.bbps.dto.sentRequest;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.billpaymentservice.bbps.dto.CustomerParamsRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.RemitterIdentity;
|
||||||
|
import com.billpaymentservice.bbps.dto.Tag;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class FetchBillForwardRequest {
|
||||||
|
private String billerId;
|
||||||
|
private String billerName;
|
||||||
|
private String billerCategory;
|
||||||
|
private String clientReqId;
|
||||||
|
private String macAdress;
|
||||||
|
private String customerMobNo;
|
||||||
|
private String remitterName;
|
||||||
|
private String paymentChannel;
|
||||||
|
private List<Tag> deviceBlockTags;
|
||||||
|
private CustomerParamsRequest customerParamsRequest;
|
||||||
|
private List<RemitterIdentity> remitterIdentity;
|
||||||
|
}
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
package com.billpaymentservice.bbps.dto.sentRequest;
|
||||||
|
|
||||||
|
import com.billpaymentservice.bbps.dto.CustomerParamsRequest;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class FetchBillValidatestForwardRequest {
|
||||||
|
|
||||||
|
private String billerId;
|
||||||
|
private String billerName;
|
||||||
|
private String billerCategory;
|
||||||
|
private String customerMobNo;
|
||||||
|
private String clientReqId;
|
||||||
|
private String macAddress;
|
||||||
|
private CustomerParamsRequest customerParamsRequest;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -20,7 +20,18 @@ import lombok.ToString;
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@Entity
|
@Entity
|
||||||
@ToString
|
@ToString(exclude = {
|
||||||
|
"billerPaymentModes",
|
||||||
|
"billerPaymentChannels",
|
||||||
|
"billerCustomerParams",
|
||||||
|
"customerParamGroups",
|
||||||
|
"billerResponseParams",
|
||||||
|
"billerAdditionalInfos",
|
||||||
|
"interchangeFeeConves",
|
||||||
|
"interchangeFees",
|
||||||
|
"billerPlanResponseParams"
|
||||||
|
})
|
||||||
|
|
||||||
@Table(name = "biller_details")
|
@Table(name = "biller_details")
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public class BillerDetails {
|
public class BillerDetails {
|
||||||
@@ -140,10 +151,12 @@ 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 =
|
* OneToMany(mappedBy = "biller", cascade = CascadeType.ALL, orphanRemoval
|
||||||
* true) private List<AdditionalInfo> billerAdditionalInfoPayments;
|
* =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;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.billpaymentservice.bbps.repository;
|
package com.billpaymentservice.bbps.repository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@@ -8,4 +10,8 @@ import com.billpaymentservice.bbps.entites.BillInitiate;
|
|||||||
@Repository
|
@Repository
|
||||||
public interface BillInitateRepository extends JpaRepository<BillInitiate, String> {
|
public interface BillInitateRepository extends JpaRepository<BillInitiate, String> {
|
||||||
|
|
||||||
|
Optional<BillInitiate> findByTxnId(String clientReqId);
|
||||||
|
|
||||||
|
Optional<BillInitiate> findByReqId(String clientReqId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import java.util.Optional;
|
|||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import com.billpaymentservice.bbps.entites.BillerDetails;
|
import com.billpaymentservice.bbps.entites.BillerDetails;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
package com.billpaymentservice.bbps.repository;
|
package com.billpaymentservice.bbps.repository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
import com.billpaymentservice.bbps.entites.PaymentInitiate;
|
import com.billpaymentservice.bbps.entites.PaymentInitiate;
|
||||||
|
|
||||||
public interface PaymentIntiateRepository extends JpaRepository<PaymentInitiate, String> {
|
public interface PaymentIntiateRepository extends JpaRepository<PaymentInitiate, String> {
|
||||||
|
|
||||||
|
Optional<PaymentInitiate> findByReqId(String clientReqId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,17 +2,23 @@ package com.billpaymentservice.bbps.service;
|
|||||||
|
|
||||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||||
import com.billpaymentservice.bbps.dto.request.BillFetchByBillIdRequest;
|
import com.billpaymentservice.bbps.dto.request.BillFetchByBillIdRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.request.BillFetchByClientIdRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.request.BillValidateByClientIdRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.FetchBillRequest;
|
import com.billpaymentservice.bbps.dto.request.FetchBillRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.FetchBillValidatestRequest;
|
import com.billpaymentservice.bbps.dto.request.FetchBillValidatestRequest;
|
||||||
|
|
||||||
public interface AgentService {
|
public interface AgentService {
|
||||||
|
|
||||||
public ResponseModel initiateBillFetch(FetchBillRequest fetchBillRequest);
|
ResponseModel initiateBillFetch(FetchBillRequest fetchBillRequest);
|
||||||
|
|
||||||
public ResponseModel fetchBillById(BillFetchByBillIdRequest billFetchByBillIdRequest);
|
ResponseModel fetchBillById(BillFetchByBillIdRequest billFetchByBillIdRequest);
|
||||||
|
|
||||||
public ResponseModel initiateBillValidate(FetchBillValidatestRequest fetchBillValidateRequest);
|
ResponseModel initiateBillValidate(FetchBillValidatestRequest fetchBillValidateRequest);
|
||||||
|
|
||||||
public ResponseModel initiateBillValidateByBillId(BillFetchByBillIdRequest billRequest);
|
ResponseModel initiateBillValidateByBillId(BillFetchByBillIdRequest billRequest);
|
||||||
|
|
||||||
|
ResponseModel fetchBillByClientReqId(BillFetchByClientIdRequest billFetchByClientIdRequest);
|
||||||
|
|
||||||
|
ResponseModel fetchBillValidateByClientReqId( BillValidateByClientIdRequest billValidateByClientIdRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ package com.billpaymentservice.bbps.service;
|
|||||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||||
import com.billpaymentservice.bbps.dto.request.AllMasterOptionsRequest;
|
import com.billpaymentservice.bbps.dto.request.AllMasterOptionsRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.ComplainStatusRequest;
|
import com.billpaymentservice.bbps.dto.request.ComplainStatusRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.request.ReOpenComplain;
|
||||||
|
import com.billpaymentservice.bbps.dto.request.TxnStatusRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.request.ViewAllComplaintsRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.ComplaintRequestDTO;
|
import com.billpaymentservice.bbps.dto.request.ComplaintRequestDTO;
|
||||||
import com.billpaymentservice.bbps.dto.request.GetTicketLatestStausRequest;
|
import com.billpaymentservice.bbps.dto.request.GetTicketLatestStausRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.TxnStatusRequest;
|
import com.billpaymentservice.bbps.dto.request.TxnStatusRequest;
|
||||||
@@ -22,6 +25,7 @@ public interface ComplainService {
|
|||||||
|
|
||||||
ResponseModel checkTxnStatus(TxnStatusRequest request);
|
ResponseModel checkTxnStatus(TxnStatusRequest request);
|
||||||
|
|
||||||
|
|
||||||
ResponseModel ViewAllComplaints(ViewAllComplaintsTicketsRequest request);
|
ResponseModel ViewAllComplaints(ViewAllComplaintsTicketsRequest request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.billpaymentservice.bbps.service;
|
|||||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||||
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
|
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.TransactionStatusRequest;
|
import com.billpaymentservice.bbps.dto.request.TransactionStatusRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.request.TrasactionStatusByClientReqIdRequest;
|
||||||
|
|
||||||
public interface PaymentService {
|
public interface PaymentService {
|
||||||
|
|
||||||
@@ -10,5 +11,6 @@ public interface PaymentService {
|
|||||||
|
|
||||||
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest);
|
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest);
|
||||||
|
|
||||||
|
ResponseModel checkTrasactionStatusByClientReqId(TrasactionStatusByClientReqIdRequest transactionStatusRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.billpaymentservice.bbps.serviceImpl;
|
package com.billpaymentservice.bbps.serviceImpl;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -13,11 +14,15 @@ import org.springframework.web.client.RestClient;
|
|||||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||||
import com.billpaymentservice.bbps.dto.request.BillFetchByBillIdRequest;
|
import com.billpaymentservice.bbps.dto.request.BillFetchByBillIdRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.request.BillFetchByClientIdRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.request.BillValidateByClientIdRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.FetchBillRequest;
|
import com.billpaymentservice.bbps.dto.request.FetchBillRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.FetchBillValidatestRequest;
|
import com.billpaymentservice.bbps.dto.request.FetchBillValidatestRequest;
|
||||||
import com.billpaymentservice.bbps.dto.response.BillDataResponse;
|
import com.billpaymentservice.bbps.dto.response.BillDataResponse;
|
||||||
import com.billpaymentservice.bbps.dto.response.FetchBillResponse;
|
import com.billpaymentservice.bbps.dto.response.FetchBillResponse;
|
||||||
import com.billpaymentservice.bbps.dto.response.FetchBillValidateResponse;
|
import com.billpaymentservice.bbps.dto.response.FetchBillValidateResponse;
|
||||||
|
import com.billpaymentservice.bbps.dto.sentRequest.FetchBillForwardRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.sentRequest.FetchBillValidatestForwardRequest;
|
||||||
import com.billpaymentservice.bbps.entites.BharatConnectMaster;
|
import com.billpaymentservice.bbps.entites.BharatConnectMaster;
|
||||||
import com.billpaymentservice.bbps.entites.BillInitiate;
|
import com.billpaymentservice.bbps.entites.BillInitiate;
|
||||||
import com.billpaymentservice.bbps.entites.BillMaster;
|
import com.billpaymentservice.bbps.entites.BillMaster;
|
||||||
@@ -37,7 +42,6 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
|||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@@ -77,7 +81,7 @@ public class AgentServiceImpl implements AgentService {
|
|||||||
String txnId = helper.generateTxnId(15);
|
String txnId = helper.generateTxnId(15);
|
||||||
String requestId = fetchBillRequest.getReqId();
|
String requestId = fetchBillRequest.getReqId();
|
||||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_INTI;
|
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_INTI;
|
||||||
|
fetchBillRequest.setClientReqId(txnId);
|
||||||
helper.validateMerchant(fetchBillRequest.getMid());
|
helper.validateMerchant(fetchBillRequest.getMid());
|
||||||
|
|
||||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
@@ -89,18 +93,21 @@ public class AgentServiceImpl implements AgentService {
|
|||||||
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||||
|
FetchBillForwardRequest forwardReq = helper.fetchBillForwardRequestMap(fetchBillRequest);
|
||||||
|
|
||||||
|
String forwardJson = helper.convertObjectToJson(forwardReq);
|
||||||
String requestJson = helper.convertObjectToJson(fetchBillRequest);
|
String requestJson = helper.convertObjectToJson(fetchBillRequest);
|
||||||
|
|
||||||
// ✅ Create inbound & outbound logs
|
// ✅ Create inbound & outbound logs
|
||||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, fetchBillRequest.getMid(),
|
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, fetchBillRequest.getMid(),
|
||||||
"POST", requestJson);
|
"POST", requestJson);
|
||||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, fullUrl, "POST",
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, fullUrl, "POST",
|
||||||
requestJson);
|
forwardJson);
|
||||||
LOGGER.debug("Outbound log created successfully for txnId: {} and reqId: {}", txnId, requestId);
|
LOGGER.debug("Outbound log created successfully for txnId: {} and reqId: {}", txnId, requestId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LOGGER.info("Calling external API: {}", fullUrl);
|
LOGGER.info("Calling external API: {}", fullUrl);
|
||||||
Map<String, String> responseMap = httpService.postRequest(fullUrl, requestJson, headers);
|
Map<String, String> responseMap = httpService.postRequest(fullUrl, forwardJson, headers);
|
||||||
String responseData = responseMap.get("data");
|
String responseData = responseMap.get("data");
|
||||||
|
|
||||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
@@ -163,9 +170,7 @@ public class AgentServiceImpl implements AgentService {
|
|||||||
String reqId = billFetchByBillIdRequest.getReqId();
|
String reqId = billFetchByBillIdRequest.getReqId();
|
||||||
String billId = billFetchByBillIdRequest.getBillId();
|
String billId = billFetchByBillIdRequest.getBillId();
|
||||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + billFetchByBillIdRequest.getBillId();
|
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + billFetchByBillIdRequest.getBillId();
|
||||||
|
|
||||||
helper.validateMerchant(billFetchByBillIdRequest.getMid());
|
helper.validateMerchant(billFetchByBillIdRequest.getMid());
|
||||||
|
|
||||||
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());
|
||||||
@@ -204,7 +209,7 @@ public class AgentServiceImpl implements AgentService {
|
|||||||
LOGGER.info("Current Bill Status: {}", status);
|
LOGGER.info("Current Bill Status: {}", status);
|
||||||
|
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
helper.saveOrUpdateBillerData(responseWrapper, billFetchByBillIdRequest);
|
helper.saveOrUpdateBillData(responseWrapper, billFetchByBillIdRequest, txnId);
|
||||||
LOGGER.info("Bill data saved successfully for billId: {}", billId);
|
LOGGER.info("Bill data saved successfully for billId: {}", billId);
|
||||||
|
|
||||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||||
@@ -222,7 +227,7 @@ public class AgentServiceImpl implements AgentService {
|
|||||||
String txnId = helper.generateTxnId(15);
|
String txnId = helper.generateTxnId(15);
|
||||||
String reqId = billFetchByBillIdRequest.getReqId();
|
String reqId = billFetchByBillIdRequest.getReqId();
|
||||||
String billId = billFetchByBillIdRequest.getBillId();
|
String billId = billFetchByBillIdRequest.getBillId();
|
||||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + "43f61299-7682-4586-b298-1f8828dcaa46";
|
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + billFetchByBillIdRequest.getBillId();
|
||||||
|
|
||||||
LOGGER.info("Initiating {} API for billId={} and reqId={}", apiName, billId, reqId);
|
LOGGER.info("Initiating {} API for billId={} and reqId={}", apiName, billId, reqId);
|
||||||
|
|
||||||
@@ -260,7 +265,7 @@ public class AgentServiceImpl implements AgentService {
|
|||||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||||
|
|
||||||
helper.saveOrUpdateBillerData(responseWrapper, billFetchByBillIdRequest);
|
helper.saveOrUpdateBillData(responseWrapper, billFetchByBillIdRequest, txnId);
|
||||||
LOGGER.info("Bill data saved successfully for billId={} | Status={}", billId, generalResp.getStatus());
|
LOGGER.info("Bill data saved successfully for billId={} | Status={}", billId, generalResp.getStatus());
|
||||||
|
|
||||||
return responseModel;
|
return responseModel;
|
||||||
@@ -274,14 +279,13 @@ public class AgentServiceImpl implements AgentService {
|
|||||||
@Override
|
@Override
|
||||||
public ResponseModel initiateBillValidate(FetchBillValidatestRequest fetchBillValidateRequest) {
|
public ResponseModel initiateBillValidate(FetchBillValidatestRequest fetchBillValidateRequest) {
|
||||||
|
|
||||||
|
|
||||||
LOGGER.info("Initiating bill Validate for request ID: {} and MID", fetchBillValidateRequest.getReqId(),
|
LOGGER.info("Initiating bill Validate for request ID: {} and MID", fetchBillValidateRequest.getReqId(),
|
||||||
fetchBillValidateRequest.getMid());
|
fetchBillValidateRequest.getMid());
|
||||||
String apiName = "InitiateBillValidate";
|
String apiName = "InitiateBillValidate";
|
||||||
String txnId = helper.generateTxnId(15);
|
String txnId = helper.generateTxnId(15);
|
||||||
String reqId = fetchBillValidateRequest.getReqId();
|
String reqId = fetchBillValidateRequest.getReqId();
|
||||||
String fullUrl = agentDtaUrl + BBPSConstant.BILLER_VALIDATE_URL;
|
String fullUrl = agentDtaUrl + BBPSConstant.BILLER_VALIDATE_URL;
|
||||||
|
fetchBillValidateRequest.setClientReqId(txnId);
|
||||||
helper.validateMerchant(fetchBillValidateRequest.getMid());
|
helper.validateMerchant(fetchBillValidateRequest.getMid());
|
||||||
|
|
||||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
@@ -293,25 +297,27 @@ public class AgentServiceImpl implements AgentService {
|
|||||||
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||||
|
FetchBillValidatestForwardRequest forwardReq = helper
|
||||||
|
.fetchBillValidatestForwardRequest(fetchBillValidateRequest);
|
||||||
|
|
||||||
|
String forwardJson = helper.convertObjectToJson(forwardReq);
|
||||||
|
|
||||||
String requestJson = helper.convertObjectToJson(fetchBillValidateRequest);
|
String requestJson = helper.convertObjectToJson(fetchBillValidateRequest);
|
||||||
|
|
||||||
// ✅ Create inbound & outbound logs
|
// ✅ Create inbound & outbound logs
|
||||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, fetchBillValidateRequest.getMid(),
|
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, fetchBillValidateRequest.getMid(),
|
||||||
"POST", requestJson);
|
"POST", requestJson);
|
||||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "POST",
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "POST", forwardJson);
|
||||||
requestJson);
|
|
||||||
LOGGER.debug("Outbound log created successfully for txnId: {} and reqId: {}", txnId, reqId);
|
LOGGER.debug("Outbound log created successfully for txnId: {} and reqId: {}", txnId, reqId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LOGGER.info("Calling external API: {}", fullUrl);
|
LOGGER.info("Calling external API: {}", fullUrl);
|
||||||
Map<String, String> responseMap = httpService.postRequest(fullUrl, requestJson, headers);
|
Map<String, String> responseMap = httpService.postRequest(fullUrl, forwardJson, headers);
|
||||||
String responseData = responseMap.get("data");
|
String responseData = responseMap.get("data");
|
||||||
|
|
||||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
LOGGER.debug("Response received from BBPS: {}", responseData);
|
LOGGER.debug("Response received from BBPS: {}", responseData);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||||
new TypeReference<Map<String, Object>>() {
|
new TypeReference<Map<String, Object>>() {
|
||||||
});
|
});
|
||||||
@@ -329,7 +335,6 @@ public class AgentServiceImpl implements AgentService {
|
|||||||
billMaster.setTxnId(txnId);
|
billMaster.setTxnId(txnId);
|
||||||
billMasterRepository.save(billMaster);
|
billMasterRepository.save(billMaster);
|
||||||
LOGGER.info("BillMaster saved for billId: {}", billMaster.getBillId());
|
LOGGER.info("BillMaster saved for billId: {}", billMaster.getBillId());
|
||||||
|
|
||||||
FetchBillResponse fetchBillResponse = objectMapper.convertValue(dataMap, FetchBillResponse.class);
|
FetchBillResponse fetchBillResponse = objectMapper.convertValue(dataMap, FetchBillResponse.class);
|
||||||
GeneralResp generalResponse = fetchBillResponse.getGenericResponse();
|
GeneralResp generalResponse = fetchBillResponse.getGenericResponse();
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResponse.getStatus());
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResponse.getStatus());
|
||||||
@@ -361,78 +366,207 @@ public class AgentServiceImpl implements AgentService {
|
|||||||
throw new CustomException("Invalid JSON received from API");
|
throw new CustomException("Invalid JSON received from API");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResponseModel BillvaidateByBillId(BillFetchByBillIdRequest billRequest, InboundTraceLog inboundLog) {
|
||||||
|
{
|
||||||
|
LOGGER.info("Validating bill by BILLID for request ID={} and MID={}", billRequest.getReqId(),
|
||||||
|
billRequest.getMid());
|
||||||
|
String apiName = "FetchBillById";
|
||||||
|
String txnId = helper.generateTxnId(15);
|
||||||
|
String reqId = billRequest.getReqId();
|
||||||
|
String billId = billRequest.getBillId();
|
||||||
|
String fullUrl = agentDtaUrl + BBPSConstant.BILL_VALIDATE_ID_URL + billRequest.getBillId();
|
||||||
|
;
|
||||||
|
|
||||||
|
helper.validateMerchant(billRequest.getMid());
|
||||||
|
|
||||||
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||||
|
headers.set("agentId", headersData.getAgentId());
|
||||||
|
headers.set("tenantId", headersData.getTenantId());
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||||
|
LOGGER.debug("Outbound log created successfully for FetchBillById: {}", fullUrl);
|
||||||
|
|
||||||
|
try {
|
||||||
|
LOGGER.info("Calling external API: {}", fullUrl);
|
||||||
|
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||||
|
String responseData = responseMap.get("data");
|
||||||
|
LOGGER.info("Bill FetchById Response: {}", responseData);
|
||||||
|
|
||||||
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
|
|
||||||
|
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||||
|
new TypeReference<Map<String, Object>>() {
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!dataMap.containsKey("genericResponse")) {
|
||||||
|
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||||
|
LOGGER.warn("Invalid response structure for txnId: {}", txnId);
|
||||||
|
throw new CustomException(String.valueOf(dataMap.get("message")),
|
||||||
|
String.valueOf(dataMap.get("status")),
|
||||||
|
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||||
|
String.valueOf(dataMap.get("remarks")));
|
||||||
|
}
|
||||||
|
|
||||||
|
FetchBillValidateResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||||
|
FetchBillValidateResponse.class);
|
||||||
|
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||||
|
|
||||||
|
String status = generalResp.getStatus();
|
||||||
|
LOGGER.info("Current Bill Status: {}", status);
|
||||||
|
|
||||||
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
|
System.out.println("responseWrapper:" + responseWrapper);
|
||||||
|
helper.saveBillValidation(responseWrapper, billRequest);
|
||||||
|
LOGGER.info("Bill data saved successfully for billId: {}", billId);
|
||||||
|
|
||||||
|
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||||
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
LOGGER.error("Error parsing BillById JSON: {}", e.getMessage(), e);
|
||||||
|
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||||
|
throw new CustomException("Invalid JSON received from API");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================================== Bill fetch and Bill Validate by Client Req
|
||||||
|
// Id==================================//
|
||||||
|
|
||||||
public ResponseModel BillvaidateByBillId( BillFetchByBillIdRequest billRequest,InboundTraceLog inboundLog) { {
|
@Override
|
||||||
LOGGER.info("Validating bill by BILLID for request ID={} and MID={}", billRequest.getReqId(), billRequest.getMid());
|
public ResponseModel fetchBillValidateByClientReqId(BillValidateByClientIdRequest billValidateByClientIdRequest) {
|
||||||
String apiName = "FetchBillById";
|
|
||||||
String txnId = helper.generateTxnId(15);
|
|
||||||
String reqId = billRequest.getReqId();
|
|
||||||
String billId = billRequest.getBillId();
|
|
||||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_VALIDATE_ID_URL+ billRequest.getBillId(); ;
|
|
||||||
|
|
||||||
helper.validateMerchant(billRequest.getMid());
|
String apiName = "FetchBillValidateByClientIdRequest";
|
||||||
|
String txnId = helper.generateTxnId(15);
|
||||||
|
String reqId = billValidateByClientIdRequest.getReqId();
|
||||||
|
String clientReqId = billValidateByClientIdRequest.getClientReqId();
|
||||||
|
|
||||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
Optional<BillInitiate> billInitiate = billIntiateRepository.findByReqId(clientReqId);
|
||||||
HttpHeaders headers = new HttpHeaders();
|
if (billInitiate.isEmpty()) {
|
||||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
throw new CustomException("No Bill Found for given Client Req Id");
|
||||||
headers.set("agentId", headersData.getAgentId());
|
}
|
||||||
headers.set("tenantId", headersData.getTenantId());
|
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
||||||
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
String fullUrl = agentDtaUrl + BBPSConstant.BILL_VALIDATE_BY_CLIENT_REQ_ID + billInitiate.get().getTxnId();
|
||||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
|
||||||
LOGGER.debug("Outbound log created successfully for FetchBillById: {}", fullUrl);
|
|
||||||
|
|
||||||
try {
|
helper.validateMerchant(billValidateByClientIdRequest.getMid());
|
||||||
LOGGER.info("Calling external API: {}", fullUrl);
|
|
||||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
|
||||||
String responseData = responseMap.get("data");
|
|
||||||
LOGGER.info("Bill FetchById Response: {}", responseData);
|
|
||||||
|
|
||||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
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, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
if (!dataMap.containsKey("genericResponse")) {
|
// 🔵 Create Inbound + Outbound Logs
|
||||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName,
|
||||||
LOGGER.warn("Invalid response structure for txnId: {}", txnId);
|
billValidateByClientIdRequest.getMid(), "GET", null);
|
||||||
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"))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
FetchBillValidateResponse responseWrapper = objectMapper.convertValue(dataMap, FetchBillValidateResponse.class);
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||||
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
|
||||||
|
|
||||||
String status = generalResp.getStatus();
|
try {
|
||||||
LOGGER.info("Current Bill Status: {}", status);
|
LOGGER.info("Calling BBPS API FetchBillValidateByClientReqId, URL={}", fullUrl);
|
||||||
|
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||||
|
String responseData = responseMap.get("data");
|
||||||
|
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
System.out.println("responseWrapper:"+responseWrapper);
|
|
||||||
helper.saveBillValidation(responseWrapper,billRequest);
|
|
||||||
LOGGER.info("Bill data saved successfully for billId: {}", billId);
|
|
||||||
|
|
||||||
return new ResponseModel(
|
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||||
generalResp.getMessage(),
|
new TypeReference<Map<String, Object>>() {
|
||||||
generalResp.getStatus(),
|
});
|
||||||
Integer.parseInt(generalResp.getStatusCode()),
|
|
||||||
responseWrapper
|
|
||||||
);
|
|
||||||
} catch (JsonProcessingException e) {
|
|
||||||
LOGGER.error("Error parsing BillById JSON: {}", e.getMessage(), e);
|
|
||||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
|
||||||
throw new CustomException("Invalid JSON received from API");
|
|
||||||
}
|
|
||||||
|
|
||||||
}}
|
if (!dataMap.containsKey("genericResponse")) {
|
||||||
|
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||||
|
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||||
|
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||||
|
String.valueOf(dataMap.get("remarks")));
|
||||||
|
}
|
||||||
|
|
||||||
|
FetchBillValidateResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||||
|
FetchBillValidateResponse.class);
|
||||||
|
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||||
|
|
||||||
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
|
|
||||||
|
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||||
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||||
|
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||||
|
throw new CustomException("Invalid JSON received from API");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseModel fetchBillByClientReqId(BillFetchByClientIdRequest billFetchByClientIdRequest) {
|
||||||
|
|
||||||
|
String apiName = "FetchBillByClientIdRequest";
|
||||||
|
String txnId = helper.generateTxnId(15);
|
||||||
|
String reqId = billFetchByClientIdRequest.getReqId();
|
||||||
|
String clientReqId = billFetchByClientIdRequest.getClientReqId();
|
||||||
|
|
||||||
|
Optional<BillInitiate> billInitiate = billIntiateRepository.findByReqId(clientReqId);
|
||||||
|
if (billInitiate.isEmpty()) {
|
||||||
|
throw new CustomException("No Bill Found for given Client Req Id");
|
||||||
|
}
|
||||||
|
|
||||||
|
String fullUrl = agentDtaUrl + BBPSConstant.BILL_VALIDATE_BY_CLIENT_REQ_ID + billInitiate.get().getTxnId();
|
||||||
|
|
||||||
|
helper.validateMerchant(billFetchByClientIdRequest.getMid());
|
||||||
|
|
||||||
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||||
|
headers.set("agentId", headersData.getAgentId());
|
||||||
|
headers.set("tenantId", headersData.getTenantId());
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
|
// 🔵 Create inbound + outbound logs
|
||||||
|
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, billFetchByClientIdRequest.getMid(),
|
||||||
|
"GET", null);
|
||||||
|
|
||||||
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||||
|
|
||||||
|
try {
|
||||||
|
LOGGER.info("Calling BBPS API FetchBillByClientReqId, URL={}", fullUrl);
|
||||||
|
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||||
|
String responseData = responseMap.get("data");
|
||||||
|
|
||||||
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
|
|
||||||
|
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||||
|
new TypeReference<Map<String, Object>>() {
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!dataMap.containsKey("genericResponse")) {
|
||||||
|
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||||
|
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||||
|
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||||
|
String.valueOf(dataMap.get("remarks")));
|
||||||
|
}
|
||||||
|
|
||||||
|
BillDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillDataResponse.class);
|
||||||
|
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||||
|
|
||||||
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
|
|
||||||
|
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||||
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||||
|
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||||
|
throw new CustomException("Invalid JSON received from API");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @Override public ResponseModel
|
* @Override public ResponseModel
|
||||||
@@ -621,11 +755,9 @@ public class AgentServiceImpl implements AgentService {
|
|||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseModel initiateBillValidateByBillId(BillFetchByBillIdRequest billRequest) {
|
public ResponseModel initiateBillValidateByBillId(BillFetchByBillIdRequest billRequest) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,11 +19,15 @@ import com.billpaymentservice.bbps.dto.request.ComplaintRequestDTO;
|
|||||||
import com.billpaymentservice.bbps.dto.request.GetTicketLatestStausRequest;
|
import com.billpaymentservice.bbps.dto.request.GetTicketLatestStausRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.TxnStatusRequest;
|
import com.billpaymentservice.bbps.dto.request.TxnStatusRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.ViewAllComplaintsTicketsRequest;
|
import com.billpaymentservice.bbps.dto.request.ViewAllComplaintsTicketsRequest;
|
||||||
|
|
||||||
|
import com.billpaymentservice.bbps.dto.request.ViewAllComplaintsRequest;
|
||||||
import com.billpaymentservice.bbps.dto.response.ComplaintHistoryStatusResponse;
|
import com.billpaymentservice.bbps.dto.response.ComplaintHistoryStatusResponse;
|
||||||
import com.billpaymentservice.bbps.dto.response.ComplaintResponse;
|
import com.billpaymentservice.bbps.dto.response.ComplaintResponse;
|
||||||
import com.billpaymentservice.bbps.dto.response.TicketCheckStatusResponse;
|
import com.billpaymentservice.bbps.dto.response.TicketCheckStatusResponse;
|
||||||
import com.billpaymentservice.bbps.dto.response.TxnStatusResponse;
|
import com.billpaymentservice.bbps.dto.response.TxnStatusResponse;
|
||||||
|
|
||||||
import com.billpaymentservice.bbps.dto.response.ViewAllComplaintsTicketsResponse;
|
import com.billpaymentservice.bbps.dto.response.ViewAllComplaintsTicketsResponse;
|
||||||
|
import com.billpaymentservice.bbps.dto.response.ViewAllComplaintsResponse;
|
||||||
import com.billpaymentservice.bbps.dto.response.ViewComplainByIdResponse;
|
import com.billpaymentservice.bbps.dto.response.ViewComplainByIdResponse;
|
||||||
import com.billpaymentservice.bbps.entites.BharatConnectMaster;
|
import com.billpaymentservice.bbps.entites.BharatConnectMaster;
|
||||||
import com.billpaymentservice.bbps.entites.ComplaintStatusOptionsMaster;
|
import com.billpaymentservice.bbps.entites.ComplaintStatusOptionsMaster;
|
||||||
@@ -538,9 +542,8 @@ public class ComplainServiceImpl implements ComplainService {
|
|||||||
String status = generalResp.getStatus();
|
String status = generalResp.getStatus();
|
||||||
LOGGER.info("Current Complaint ReOpen Status: {}", status);
|
LOGGER.info("Current Complaint ReOpen Status: {}", status);
|
||||||
|
|
||||||
String saveComplaint = mapperHelper.saveAllComplaints(responseWrapper, reqId, txnId);
|
String saveComplaint = mapperHelper.saveAllComplaints(responseWrapper, reqId, txnId);
|
||||||
LOGGER.info("Complaint ReOpen data saved successfully for Count History: {}",
|
LOGGER.info("Complaint ReOpen data saved successfully for Count History: {}", saveComplaint);
|
||||||
saveComplaint);
|
|
||||||
|
|
||||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||||
|
|||||||
@@ -174,6 +174,8 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, billerDetailRequest.getMid(),
|
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, billerDetailRequest.getMid(),
|
||||||
"POST", requestJson);
|
"POST", requestJson);
|
||||||
|
|
||||||
|
System.out.println( billerDataRespository.findByBillerId(billerId));
|
||||||
|
|
||||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
||||||
LOGGER.info("Calling external API: {}", fullUrl);
|
LOGGER.info("Calling external API: {}", fullUrl);
|
||||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||||
@@ -291,6 +293,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|||||||
String fullUrl = String.format("%s%s?billerName=%s&category=%s&page=%d&pagesize=%d", masterRegisterUrl,
|
String fullUrl = String.format("%s%s?billerName=%s&category=%s&page=%d&pagesize=%d", masterRegisterUrl,
|
||||||
BBPSConstant.BILLER_URL, masterRequest.getBillerName(), masterRequest.getCategory(),
|
BBPSConstant.BILLER_URL, masterRequest.getBillerName(), masterRequest.getCategory(),
|
||||||
masterRequest.getPageNo(), masterRequest.getPageSize());
|
masterRequest.getPageNo(), masterRequest.getPageSize());
|
||||||
|
LOGGER.info("Calling external API: {}", fullUrl);
|
||||||
|
|
||||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.billpaymentservice.bbps.serviceImpl;
|
package com.billpaymentservice.bbps.serviceImpl;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.modelmapper.ModelMapper;
|
import org.modelmapper.ModelMapper;
|
||||||
import org.modelmapper.convention.MatchingStrategies;
|
import org.modelmapper.convention.MatchingStrategies;
|
||||||
@@ -10,14 +11,14 @@ import org.springframework.beans.factory.annotation.Value;
|
|||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||||
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
|
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.TransactionStatusRequest;
|
import com.billpaymentservice.bbps.dto.request.TransactionStatusRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.request.TrasactionStatusByClientReqIdRequest;
|
||||||
import com.billpaymentservice.bbps.dto.response.BillPaymentResponse;
|
import com.billpaymentservice.bbps.dto.response.BillPaymentResponse;
|
||||||
import com.billpaymentservice.bbps.dto.response.ClientReqIdResponse;
|
|
||||||
import com.billpaymentservice.bbps.dto.response.TransactionStatusResponse;
|
import com.billpaymentservice.bbps.dto.response.TransactionStatusResponse;
|
||||||
|
import com.billpaymentservice.bbps.dto.sentRequest.BillPaymentForwardRequest;
|
||||||
import com.billpaymentservice.bbps.entites.AgentFundTransfer;
|
import com.billpaymentservice.bbps.entites.AgentFundTransfer;
|
||||||
import com.billpaymentservice.bbps.entites.BharatConnectMaster;
|
import com.billpaymentservice.bbps.entites.BharatConnectMaster;
|
||||||
import com.billpaymentservice.bbps.entites.BillPayment;
|
import com.billpaymentservice.bbps.entites.BillPayment;
|
||||||
@@ -35,7 +36,6 @@ import com.billpaymentservice.bbps.repository.PaymentRepository;
|
|||||||
import com.billpaymentservice.bbps.repository.TransactionMasterRepository;
|
import com.billpaymentservice.bbps.repository.TransactionMasterRepository;
|
||||||
import com.billpaymentservice.bbps.service.PaymentService;
|
import com.billpaymentservice.bbps.service.PaymentService;
|
||||||
import com.billpaymentservice.bbps.util.BBPSConstant;
|
import com.billpaymentservice.bbps.util.BBPSConstant;
|
||||||
import com.billpaymentservice.bbps.util.BillerMapperHelper;
|
|
||||||
import com.billpaymentservice.bbps.util.EntityRelationshipUtil;
|
import com.billpaymentservice.bbps.util.EntityRelationshipUtil;
|
||||||
import com.billpaymentservice.bbps.util.Helper;
|
import com.billpaymentservice.bbps.util.Helper;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
@@ -58,7 +58,6 @@ public class PaymentServiceImpl implements PaymentService {
|
|||||||
private final PaymentIntiateRepository paymentIntiateRepository;
|
private final PaymentIntiateRepository paymentIntiateRepository;
|
||||||
private final TransactionMasterRepository transactionMasterRepository;
|
private final TransactionMasterRepository transactionMasterRepository;
|
||||||
private final AgentFundTransferRepository agentFundTransferRepository;
|
private final AgentFundTransferRepository agentFundTransferRepository;
|
||||||
private final BillerMapperHelper mapperHelper;
|
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(PaymentServiceImpl.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(PaymentServiceImpl.class);
|
||||||
|
|
||||||
@@ -66,7 +65,7 @@ public class PaymentServiceImpl implements PaymentService {
|
|||||||
Helper helper, PaymentRepository paymentRepository, InboundTraceLogRepository inboundTraceLogRepository,
|
Helper helper, PaymentRepository paymentRepository, InboundTraceLogRepository inboundTraceLogRepository,
|
||||||
OutboundTraceLogRepository outboundTraceLogRepository, PaymentIntiateRepository paymentIntiateRepository,
|
OutboundTraceLogRepository outboundTraceLogRepository, PaymentIntiateRepository paymentIntiateRepository,
|
||||||
TransactionMasterRepository transactionMasterRepository,
|
TransactionMasterRepository transactionMasterRepository,
|
||||||
AgentFundTransferRepository agentFundTransferRepository, BillerMapperHelper mapperHelper) {
|
AgentFundTransferRepository agentFundTransferRepository) {
|
||||||
this.beneficiaryDetailsRepository = beneficiaryDetailsRepository;
|
this.beneficiaryDetailsRepository = beneficiaryDetailsRepository;
|
||||||
this.httpService = httpService;
|
this.httpService = httpService;
|
||||||
this.helper = helper;
|
this.helper = helper;
|
||||||
@@ -76,167 +75,170 @@ public class PaymentServiceImpl implements PaymentService {
|
|||||||
this.paymentIntiateRepository = paymentIntiateRepository;
|
this.paymentIntiateRepository = paymentIntiateRepository;
|
||||||
this.transactionMasterRepository = transactionMasterRepository;
|
this.transactionMasterRepository = transactionMasterRepository;
|
||||||
this.agentFundTransferRepository = agentFundTransferRepository;
|
this.agentFundTransferRepository = agentFundTransferRepository;
|
||||||
this.mapperHelper = mapperHelper;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseModel initiatePayment(BillPaymentRequest billPaymentRequest) {
|
public ResponseModel initiatePayment(BillPaymentRequest billPaymentRequest) {
|
||||||
String apiName = "InitiatePayment";
|
String apiName = "InitiatePayment";
|
||||||
String txnId = helper.generateTxnId(15);
|
String txnId = helper.generateTxnId(15);
|
||||||
String requestId = billPaymentRequest.getReqId();
|
String requestId = billPaymentRequest.getReqId();
|
||||||
String url = paymentUrl + BBPSConstant.PAYMENT_URL;
|
String url = paymentUrl + BBPSConstant.PAYMENT_URL;
|
||||||
|
billPaymentRequest.setClientReqId(txnId);
|
||||||
|
LOGGER.info("Initiating payment for reqId={} and txnId={}", requestId, txnId);
|
||||||
|
|
||||||
LOGGER.info("Initiating payment for reqId={} and txnId={}", requestId, txnId);
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||||
|
headers.set("agentId", headersData.getAgentId());
|
||||||
|
headers.set("tenantId", headersData.getTenantId());
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
HttpHeaders headers = new HttpHeaders();
|
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
BillPaymentForwardRequest forwardReq =
|
||||||
headers.set("agentId", headersData.getAgentId());
|
helper.billPaymentForwardRequest(billPaymentRequest);
|
||||||
headers.set("tenantId", headersData.getTenantId());
|
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
||||||
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
String forwardjson = helper.convertObjectToJson(forwardReq);
|
||||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
|
||||||
|
|
||||||
String requestJson = helper.convertObjectToJson(billPaymentRequest);
|
|
||||||
|
|
||||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, billPaymentRequest.getMid(),
|
String requestJson = helper.convertObjectToJson(billPaymentRequest);
|
||||||
"POST", requestJson);
|
|
||||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, "POST", requestJson);
|
|
||||||
|
|
||||||
try {
|
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, billPaymentRequest.getMid(), "POST", requestJson);
|
||||||
LOGGER.info("Calling BBPS payment URL: {}", url);
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, "POST",forwardjson);
|
||||||
Map<String, String> responseMap = httpService.postRequest(url, requestJson, headers);
|
|
||||||
String responseData = responseMap.get("data");
|
|
||||||
LOGGER.info("Payment API Response: {}", responseData);
|
|
||||||
|
|
||||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
try {
|
||||||
|
LOGGER.info("Calling BBPS payment URL: {}", url);
|
||||||
|
Map<String, String> responseMap = httpService.postRequest(url, forwardjson, headers);
|
||||||
|
String responseData = responseMap.get("data");
|
||||||
|
LOGGER.info("Payment API Response: {}", responseData);
|
||||||
|
|
||||||
if (responseData == null || responseData.isEmpty()) {
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
helper.updateInboundLogFailure(inboundLog, "Empty response from BBPS", "FAILED");
|
|
||||||
LOGGER.warn("Empty response received from BBPS for txnId={}", txnId);
|
|
||||||
throw new CustomException("Empty response from BBPS server");
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
if (responseData == null || responseData.isEmpty()) {
|
||||||
new TypeReference<Map<String, Object>>() {
|
helper.updateInboundLogFailure(inboundLog, "Empty response from BBPS", "FAILED");
|
||||||
});
|
LOGGER.warn("Empty response received from BBPS for txnId={}", txnId);
|
||||||
if (!dataMap.containsKey("genericResponse")) {
|
throw new CustomException("Empty response from BBPS server");
|
||||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_STRUCTURE");
|
}
|
||||||
LOGGER.warn("Invalid response structure received for txnId={}", txnId);
|
|
||||||
throw new CustomException("Invalid response structure from BBPS");
|
|
||||||
}
|
|
||||||
|
|
||||||
BillPaymentResponse billPaymentResponse = objectMapper.convertValue(dataMap, BillPaymentResponse.class);
|
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
|
||||||
GeneralResp generalResponse = billPaymentResponse.getGenericResponse();
|
if (!dataMap.containsKey("genericResponse")) {
|
||||||
|
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_STRUCTURE");
|
||||||
|
LOGGER.warn("Invalid response structure received for txnId={}", txnId);
|
||||||
|
throw new CustomException("Invalid response structure from BBPS");
|
||||||
|
}
|
||||||
|
|
||||||
ModelMapper mapper = new ModelMapper();
|
BillPaymentResponse billPaymentResponse = objectMapper.convertValue(dataMap, BillPaymentResponse.class);
|
||||||
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
GeneralResp generalResponse = billPaymentResponse.getGenericResponse();
|
||||||
BillPayment entity = mapper.map(billPaymentResponse, BillPayment.class);
|
|
||||||
paymentRepository.save(entity);
|
|
||||||
LOGGER.info("BillPayment entity saved successfully for txnId={}", txnId);
|
|
||||||
|
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResponse.getStatus());
|
ModelMapper mapper = new ModelMapper();
|
||||||
PaymentInitiate paymentInitiate = new PaymentInitiate();
|
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||||
paymentInitiate.setTxnId(txnId);
|
BillPayment entity = mapper.map(billPaymentResponse, BillPayment.class);
|
||||||
paymentInitiate.setReqId(requestId);
|
paymentRepository.save(entity);
|
||||||
paymentInitiate.setBankTxnId(billPaymentResponse.getTxnId());
|
LOGGER.info("BillPayment entity saved successfully for txnId={}", txnId);
|
||||||
paymentInitiate.setStatus(billPaymentResponse.getStatus());
|
|
||||||
paymentIntiateRepository.save(paymentInitiate);
|
|
||||||
LOGGER.info("PaymentInitiate entry saved successfully for txnId={}", txnId);
|
|
||||||
|
|
||||||
TransactionStatusRequest transactionStatusRequest = new TransactionStatusRequest();
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResponse.getStatus());
|
||||||
transactionStatusRequest.setTxnId(billPaymentResponse.getTxnId());
|
PaymentInitiate paymentInitiate = new PaymentInitiate();
|
||||||
transactionStatusRequest.setReqId(requestId);
|
paymentInitiate.setTxnId(txnId);
|
||||||
|
paymentInitiate.setReqId(requestId);
|
||||||
|
paymentInitiate.setBankTxnId(billPaymentResponse.getTxnId());
|
||||||
|
paymentInitiate.setStatus(billPaymentResponse.getStatus());
|
||||||
|
paymentIntiateRepository.save(paymentInitiate);
|
||||||
|
LOGGER.info("PaymentInitiate entry saved successfully for txnId={}", txnId);
|
||||||
|
|
||||||
try {
|
TransactionStatusRequest transactionStatusRequest = new TransactionStatusRequest();
|
||||||
Thread.sleep(2000);
|
transactionStatusRequest.setTxnId(billPaymentResponse.getTxnId());
|
||||||
} catch (InterruptedException e) {
|
transactionStatusRequest.setReqId(requestId);
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
LOGGER.warn("Thread interrupted during payment delay: {}", e.getMessage());
|
|
||||||
}
|
|
||||||
LOGGER.info("Checking transaction status for txnId={}", billPaymentResponse.getTxnId());
|
|
||||||
return checkTrasactionStatus(transactionStatusRequest, inboundLog);
|
|
||||||
|
|
||||||
} catch (JsonProcessingException e) {
|
try {
|
||||||
LOGGER.error("JSON Parsing Error in initiatePayment: {}", e.getMessage(), e);
|
Thread.sleep(9000);
|
||||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
} catch (InterruptedException e) {
|
||||||
throw new CustomException("Invalid JSON received from API");
|
Thread.currentThread().interrupt();
|
||||||
}
|
LOGGER.warn("Thread interrupted during payment delay: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
LOGGER.info("Checking transaction status for txnId={}", billPaymentResponse.getTxnId());
|
||||||
|
return checkTrasactionStatus(transactionStatusRequest, inboundLog);
|
||||||
|
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
LOGGER.error("JSON Parsing Error in initiatePayment: {}", e.getMessage(), e);
|
||||||
|
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||||
|
throw new CustomException("Invalid JSON received from API");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest,
|
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest, InboundTraceLog inboundLog) {
|
||||||
InboundTraceLog inboundLog) {
|
String apiName = "CheckTransactionStatus";
|
||||||
String apiName = "CheckTransactionStatus";
|
String txnId = helper.generateTxnId(15);
|
||||||
String txnId = helper.generateTxnId(15);
|
String requestId = transactionStatusRequest.getReqId();
|
||||||
String requestId = transactionStatusRequest.getReqId();
|
|
||||||
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
|
|
||||||
|
|
||||||
LOGGER.info("Checking transaction status (internal) for txnId={} and reqId={}",
|
|
||||||
transactionStatusRequest.getTxnId(), requestId);
|
|
||||||
|
|
||||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
|
||||||
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();
|
LOGGER.info("Checking transaction status (internal) for txnId={} and reqId={}", transactionStatusRequest.getTxnId(), requestId);
|
||||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, "GET", null);
|
|
||||||
|
|
||||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
String responseData = responseMap.get("data");
|
HttpHeaders headers = new HttpHeaders();
|
||||||
LOGGER.info("Transaction status response: {}", responseData);
|
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||||
|
headers.set("agentId", headersData.getAgentId());
|
||||||
|
headers.set("tenantId", headersData.getTenantId());
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, "GET", null);
|
||||||
|
|
||||||
try {
|
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
String responseData = responseMap.get("data");
|
||||||
new TypeReference<Map<String, Object>>() {
|
LOGGER.info("Transaction status response: {}", responseData);
|
||||||
});
|
|
||||||
if (!dataMap.containsKey("generalResp")) {
|
|
||||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
|
||||||
LOGGER.warn("Invalid transaction status response for txnId={}", transactionStatusRequest.getTxnId());
|
|
||||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
|
||||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
|
||||||
String.valueOf(dataMap.get("remarks")));
|
|
||||||
}
|
|
||||||
|
|
||||||
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
TransactionStatusResponse.class);
|
|
||||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
|
||||||
LOGGER.info("Transaction status received: {}", generalResp.getStatus());
|
|
||||||
|
|
||||||
ModelMapper mapper = new ModelMapper();
|
try {
|
||||||
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
|
||||||
TransactionMaster transactionMaster = mapper.map(responseWrapper.getTransactionDAO(),
|
if (!dataMap.containsKey("generalResp")) {
|
||||||
TransactionMaster.class);
|
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||||
transactionMaster.setTxnId(txnId);
|
LOGGER.warn("Invalid transaction status response for txnId={}", transactionStatusRequest.getTxnId());
|
||||||
transactionMaster.setReqId(transactionStatusRequest.getReqId());
|
throw new CustomException(
|
||||||
EntityRelationshipUtil.linkTransactionMasterRelationships(transactionMaster);
|
String.valueOf(dataMap.get("message")),
|
||||||
transactionMasterRepository.save(transactionMaster);
|
String.valueOf(dataMap.get("status")),
|
||||||
LOGGER.info("TransactionMaster saved successfully for txnId={}", txnId);
|
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||||
|
String.valueOf(dataMap.get("remarks"))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
AgentFundTransfer agentFundTransfer = mapper.map(responseWrapper.getAgentFundTransfer(),
|
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
|
||||||
AgentFundTransfer.class);
|
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||||
agentFundTransfer.setTxnId(txnId);
|
LOGGER.info("Transaction status received: {}", generalResp.getStatus());
|
||||||
agentFundTransfer.setReqId(transactionStatusRequest.getReqId());
|
|
||||||
agentFundTransfer.setTransactionMasterId(transactionMaster.getBankTxnId());
|
|
||||||
agentFundTransferRepository.save(agentFundTransfer);
|
|
||||||
LOGGER.info("AgentFundTransfer entry saved successfully for txnId={}", txnId);
|
|
||||||
|
|
||||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
ModelMapper mapper = new ModelMapper();
|
||||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||||
|
TransactionMaster transactionMaster = mapper.map(responseWrapper.getTransactionDAO(), TransactionMaster.class);
|
||||||
|
transactionMaster.setTxnId(txnId);
|
||||||
|
transactionMaster.setReqId(transactionStatusRequest.getReqId());
|
||||||
|
EntityRelationshipUtil.linkTransactionMasterRelationships(transactionMaster);
|
||||||
|
transactionMasterRepository.save(transactionMaster);
|
||||||
|
LOGGER.info("TransactionMaster saved successfully for txnId={}", txnId);
|
||||||
|
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
AgentFundTransfer agentFundTransfer = mapper.map(responseWrapper.getAgentFundTransfer(), AgentFundTransfer.class);
|
||||||
return responseModel;
|
agentFundTransfer.setTxnId(txnId);
|
||||||
|
agentFundTransfer.setReqId(transactionStatusRequest.getReqId());
|
||||||
|
agentFundTransfer.setTransactionMasterId(transactionMaster.getBankTxnId());
|
||||||
|
agentFundTransferRepository.save(agentFundTransfer);
|
||||||
|
LOGGER.info("AgentFundTransfer entry saved successfully for txnId={}", txnId);
|
||||||
|
|
||||||
} catch (JsonProcessingException e) {
|
ResponseModel responseModel = new ResponseModel(
|
||||||
LOGGER.error("Error parsing transaction status JSON: {}", e.getMessage(), e);
|
generalResp.getMessage(),
|
||||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
generalResp.getStatus(),
|
||||||
throw new CustomException("Invalid JSON received from API");
|
Integer.parseInt(generalResp.getStatusCode()),
|
||||||
}
|
responseWrapper
|
||||||
|
);
|
||||||
|
|
||||||
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
|
return responseModel;
|
||||||
|
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
LOGGER.error("Error parsing transaction status JSON: {}", e.getMessage(), e);
|
||||||
|
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||||
|
throw new CustomException("Invalid JSON received from API");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -246,184 +248,276 @@ public class PaymentServiceImpl implements PaymentService {
|
|||||||
String apiName = "checkTrasactionStatus";
|
String apiName = "checkTrasactionStatus";
|
||||||
String requestId = transactionStatusRequest.getReqId();
|
String requestId = transactionStatusRequest.getReqId();
|
||||||
String requestJson = helper.convertObjectToJson(transactionStatusRequest);
|
String requestJson = helper.convertObjectToJson(transactionStatusRequest);
|
||||||
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
|
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
|
||||||
|
|
||||||
LOGGER.info("Checking transaction status (public) for txnId={} and reqId={}",
|
LOGGER.info("Checking transaction status (public) for txnId={} and reqId={}", transactionStatusRequest.getTxnId(), requestId);
|
||||||
transactionStatusRequest.getTxnId(), requestId);
|
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
|
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, transactionStatusRequest.getMid(), "POST", requestJson);
|
||||||
transactionStatusRequest.getMid(), "POST", requestJson);
|
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, "GET", null);
|
||||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, "GET", null);
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
|
||||||
|
|
||||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||||
String responseData = responseMap.get("data");
|
String responseData = responseMap.get("data");
|
||||||
LOGGER.info("Transaction status response data: {}", responseData);
|
LOGGER.info("Transaction status response data: {}", responseData);
|
||||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
|
||||||
new TypeReference<Map<String, Object>>() {
|
if (!dataMap.containsKey("generalResp")) {
|
||||||
});
|
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
||||||
if (!dataMap.containsKey("generalResp")) {
|
LOGGER.warn("Invalid transaction status response for txnId={} from BBPS", transactionStatusRequest.getTxnId());
|
||||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
throw new CustomException(
|
||||||
LOGGER.warn("Invalid transaction status response for txnId={} from BBPS",
|
String.valueOf(dataMap.get("message")),
|
||||||
transactionStatusRequest.getTxnId());
|
String.valueOf(dataMap.get("status")),
|
||||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
String.valueOf(dataMap.get("remarks"))
|
||||||
String.valueOf(dataMap.get("remarks")));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
|
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
|
||||||
TransactionStatusResponse.class);
|
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
|
||||||
|
|
||||||
String status = generalResp.getStatus();
|
String status = generalResp.getStatus();
|
||||||
LOGGER.info("Current transaction status: {}", status);
|
LOGGER.info("Current transaction status: {}", status);
|
||||||
|
|
||||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
ResponseModel responseModel = new ResponseModel(
|
||||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
generalResp.getMessage(),
|
||||||
|
generalResp.getStatus(),
|
||||||
|
Integer.parseInt(generalResp.getStatusCode()),
|
||||||
|
responseWrapper
|
||||||
|
);
|
||||||
|
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
return responseModel;
|
return responseModel;
|
||||||
|
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage(), e);
|
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage(), e);
|
||||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||||
throw new CustomException("Invalid JSON received from API");
|
throw new CustomException("Invalid JSON received from API");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseModel checkTrasactionStatusByClientReqId(TrasactionStatusByClientReqIdRequest transactionStatusRequest) {
|
||||||
|
|
||||||
|
helper.validateMerchant(transactionStatusRequest.getMid());
|
||||||
|
|
||||||
|
String txnID = helper.generateTxnId(15);
|
||||||
|
String apiName = "checkTrasactionStatusbyClientReqId";
|
||||||
|
String requestId = transactionStatusRequest.getReqId();
|
||||||
|
String clientReqId = transactionStatusRequest.getClientReqId();
|
||||||
|
String requestJson = helper.convertObjectToJson(transactionStatusRequest);
|
||||||
|
|
||||||
|
LOGGER.info("Checking transaction status for clientReqId={} and reqId={}", clientReqId, requestId);
|
||||||
|
|
||||||
|
// Fetch Txn from DB
|
||||||
|
Optional<PaymentInitiate> paymentInitiate = paymentIntiateRepository.findByReqId(clientReqId);
|
||||||
|
if (paymentInitiate.isEmpty()) {
|
||||||
|
throw new CustomException("No Transaction Found for given Client Req Id");
|
||||||
|
}
|
||||||
|
|
||||||
|
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_BY_CLIENT_REQ_ID_URL + paymentInitiate.get().getTxnId();
|
||||||
|
|
||||||
|
// Prepare headers
|
||||||
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||||
|
headers.set("agentId", headersData.getAgentId());
|
||||||
|
headers.set("tenantId", headersData.getTenantId());
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
|
||||||
|
// 🔵 Create Inbound + Outbound Logs
|
||||||
|
InboundTraceLog inboundLog = helper.createInboundLog(
|
||||||
|
requestId, txnID, apiName, transactionStatusRequest.getMid(), "POST", requestJson);
|
||||||
|
|
||||||
|
OutboundTraceLog outboundLog = helper.createOutboundLog(
|
||||||
|
txnID, requestId, apiName, url, "GET", null);
|
||||||
|
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
|
try {
|
||||||
|
LOGGER.info("Calling BBPS Transaction Status API URL={}", url);
|
||||||
|
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||||
|
|
||||||
|
String responseData = responseMap.get("data");
|
||||||
|
LOGGER.info("Transaction Status Response: {}", responseData);
|
||||||
|
|
||||||
|
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
|
|
||||||
|
// Parse response
|
||||||
|
Map<String, Object> dataMap = objectMapper.readValue(
|
||||||
|
responseData, new TypeReference<Map<String, Object>>() {});
|
||||||
|
|
||||||
|
// Validate response
|
||||||
|
if (!dataMap.containsKey("generalResp")) {
|
||||||
|
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||||
|
|
||||||
|
LOGGER.warn("Invalid transaction status response for clientReqId={} | Response={}",
|
||||||
|
clientReqId, responseData);
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
LOGGER.info("Transaction Status for clientReqId={} => {}", clientReqId, generalResp.getStatus());
|
||||||
|
|
||||||
|
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||||
|
|
||||||
|
return new ResponseModel(
|
||||||
|
generalResp.getMessage(),
|
||||||
|
generalResp.getStatus(),
|
||||||
|
Integer.parseInt(generalResp.getStatusCode()),
|
||||||
|
responseWrapper
|
||||||
|
);
|
||||||
|
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
LOGGER.error("Error parsing JSON in transaction status API: {}", e.getMessage(), e);
|
||||||
|
|
||||||
|
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||||
|
|
||||||
|
throw new CustomException("Invalid JSON received from API");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
/* PollBack logic for the fetchTxnByTxnId API
|
||||||
|
* @Override public ResponseModel fetchTxnByTxnId(BillFetchByBillIdRequest
|
||||||
|
* billFetchByBillIdRequest) {
|
||||||
|
*
|
||||||
|
* String billId = billFetchByBillIdRequest.getBillId(); String fullUrl =
|
||||||
|
* agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID+billId;
|
||||||
|
* System.out.print(fullUrl);
|
||||||
|
*
|
||||||
|
* BeneficiaryDetails
|
||||||
|
* headersData=beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||||
|
*
|
||||||
|
* HttpHeaders headers = new HttpHeaders();
|
||||||
|
* headers.set("x-digiledge-key",headersData.getXDigiledgeKey());
|
||||||
|
* headers.set("agentId", headersData.getAgentId()); headers.set("tenantId",
|
||||||
|
* headersData.getTenantId());
|
||||||
|
* headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
*
|
||||||
|
* Map<String, String> responseMap = httpService.getRequest(fullUrl,headers);
|
||||||
|
* String responseData = responseMap.get("data"); log.info("data is :{}",
|
||||||
|
* responseData);
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
*
|
||||||
|
* try { Map<String, Object> dataMap = objectMapper.readValue(responseData, new
|
||||||
|
* TypeReference<Map<String, Object>>() { }); if
|
||||||
|
* (!dataMap.containsKey("genericResponse")) { throw new
|
||||||
|
* CustomException(String.valueOf(dataMap.get("message")), // message
|
||||||
|
* String.valueOf(dataMap.get("status")), // status
|
||||||
|
* Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode
|
||||||
|
* (int) String.valueOf(dataMap.get("remarks")) ); }
|
||||||
|
*
|
||||||
|
* BillDataResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||||
|
* BillDataResponse.class);
|
||||||
|
*
|
||||||
|
* GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||||
|
*
|
||||||
|
* ResponseModel responseModel=new ResponseModel( generalResp.getMessage(),
|
||||||
|
* generalResp.getStatus(), Integer.parseInt(generalResp.getStatusCode()),
|
||||||
|
* responseWrapper);
|
||||||
|
*
|
||||||
|
* return responseModel;
|
||||||
|
*
|
||||||
|
* } catch (JsonProcessingException e) {
|
||||||
|
* LOGGER.error("Error parsing responseData JSON: {}", e.getMessage()); throw
|
||||||
|
* new CustomException("Invalid JSON received from API"); }
|
||||||
|
*
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PollBack logic for the fetchTxnByTxnId API
|
* public ResponseModel checkTrasactionStatus(TransactionStatusRequest
|
||||||
*
|
* transactionStatusRequest,InboundTraceLog inboundLog) { String apiName =
|
||||||
* @Override public ResponseModel fetchTxnByTxnId(BillFetchByBillIdRequest
|
* "CheckTransactionStatus"; String txnId = helper.generateTxnId(15); //our
|
||||||
* billFetchByBillIdRequest) {
|
* genrated txnId String requestId = transactionStatusRequest.getReqId(); String
|
||||||
*
|
* url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL +
|
||||||
* String billId = billFetchByBillIdRequest.getBillId(); String fullUrl =
|
* transactionStatusRequest.getTxnId(); ;
|
||||||
* agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID+billId;
|
*
|
||||||
* System.out.print(fullUrl);
|
* BharatConnectMaster headersData =
|
||||||
*
|
* beneficiaryDetailsRepository.findByOrgId("ORG001"); HttpHeaders headers = new
|
||||||
* BeneficiaryDetails
|
* HttpHeaders(); headers.set("x-digiledge-key",
|
||||||
* headersData=beneficiaryDetailsRepository.findByOrgId("ORG001");
|
* headersData.getXDigiledgeKey()); headers.set("agentId",
|
||||||
*
|
* headersData.getAgentId()); headers.set("tenantId",
|
||||||
* HttpHeaders headers = new HttpHeaders();
|
* headersData.getTenantId());
|
||||||
* headers.set("x-digiledge-key",headersData.getXDigiledgeKey());
|
* headers.setContentType(MediaType.APPLICATION_JSON); ObjectMapper objectMapper
|
||||||
* headers.set("agentId", headersData.getAgentId()); headers.set("tenantId",
|
* = new ObjectMapper();
|
||||||
* headersData.getTenantId());
|
*
|
||||||
* headers.setContentType(MediaType.APPLICATION_JSON);
|
* OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId,
|
||||||
*
|
* apiName, url, "GET", null);
|
||||||
* Map<String, String> responseMap = httpService.getRequest(fullUrl,headers);
|
*
|
||||||
* String responseData = responseMap.get("data"); log.info("data is :{}",
|
* long startTime = System.currentTimeMillis(); long maxWaitTimeMs = 40000; long
|
||||||
* responseData);
|
* intervalMs = 5000;
|
||||||
*
|
*
|
||||||
*
|
* while (true) { Map<String, String> responseMap = httpService.getRequest(url,
|
||||||
* ObjectMapper objectMapper = new ObjectMapper();
|
* headers); String responseData = responseMap.get("data");
|
||||||
*
|
* LOGGER.info("Transaction status response: {}", responseData);
|
||||||
* try { Map<String, Object> dataMap = objectMapper.readValue(responseData, new
|
*
|
||||||
* TypeReference<Map<String, Object>>() { }); if
|
* helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||||
* (!dataMap.containsKey("genericResponse")) { throw new
|
*
|
||||||
* CustomException(String.valueOf(dataMap.get("message")), // message
|
* try { Map<String, Object> dataMap = objectMapper.readValue(responseData, new
|
||||||
* String.valueOf(dataMap.get("status")), // status
|
* TypeReference<Map<String, Object>>() {});
|
||||||
* Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode
|
*
|
||||||
* (int) String.valueOf(dataMap.get("remarks")) ); }
|
* if (!dataMap.containsKey("generalResp")) {
|
||||||
*
|
* helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||||
* BillDataResponse responseWrapper = objectMapper.convertValue(dataMap,
|
* throw new CustomException( String.valueOf(dataMap.get("message")),
|
||||||
* BillDataResponse.class);
|
* String.valueOf(dataMap.get("status")),
|
||||||
*
|
* Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
||||||
* GeneralResp generalResp = responseWrapper.getGenericResponse();
|
* String.valueOf(dataMap.get("remarks")) ); }
|
||||||
*
|
*
|
||||||
* ResponseModel responseModel=new ResponseModel( generalResp.getMessage(),
|
* TransactionStatusResponse responseWrapper =
|
||||||
* generalResp.getStatus(), Integer.parseInt(generalResp.getStatusCode()),
|
* objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
|
||||||
* responseWrapper);
|
* GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||||
*
|
*
|
||||||
* return responseModel;
|
* String status = generalResp.getStatus();
|
||||||
*
|
* LOGGER.info("Current transaction status: {}", status);
|
||||||
* } catch (JsonProcessingException e) {
|
*
|
||||||
* LOGGER.error("Error parsing responseData JSON: {}", e.getMessage()); throw
|
* if ("INPROGRESS".equalsIgnoreCase(status)) { if (System.currentTimeMillis() -
|
||||||
* new CustomException("Invalid JSON received from API"); }
|
* startTime > maxWaitTimeMs) { helper.updateInboundLogFailure(inboundLog,
|
||||||
*
|
* "Timeout after 40 seconds", "FAILED"); throw new
|
||||||
* }
|
* CustomException("Timeout waiting for transaction completion", "FAILED", 408,
|
||||||
*/
|
* "Transaction still in progress"); }
|
||||||
|
*
|
||||||
/*
|
* Thread.sleep(intervalMs); continue; }
|
||||||
* public ResponseModel checkTrasactionStatus(TransactionStatusRequest
|
*
|
||||||
* transactionStatusRequest,InboundTraceLog inboundLog) { String apiName =
|
* ResponseModel responseModel = new ResponseModel( generalResp.getMessage(),
|
||||||
* "CheckTransactionStatus"; String txnId = helper.generateTxnId(15); //our
|
* generalResp.getStatus(), Integer.parseInt(generalResp.getStatusCode()),
|
||||||
* genrated txnId String requestId = transactionStatusRequest.getReqId(); String
|
* responseWrapper );
|
||||||
* url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL +
|
*
|
||||||
* transactionStatusRequest.getTxnId(); ;
|
* helper.updateInboundLogSuccess(inboundLog, responseData,
|
||||||
*
|
* generalResp.getStatus()); return responseModel;
|
||||||
* BharatConnectMaster headersData =
|
*
|
||||||
* beneficiaryDetailsRepository.findByOrgId("ORG001"); HttpHeaders headers = new
|
* } catch (JsonProcessingException e) {
|
||||||
* HttpHeaders(); headers.set("x-digiledge-key",
|
* LOGGER.error("Error parsing transaction status JSON: {}", e.getMessage());
|
||||||
* headersData.getXDigiledgeKey()); headers.set("agentId",
|
* helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||||
* headersData.getAgentId()); headers.set("tenantId",
|
* throw new CustomException("Invalid JSON received from API"); } catch
|
||||||
* headersData.getTenantId());
|
* (InterruptedException e) { Thread.currentThread().interrupt();
|
||||||
* headers.setContentType(MediaType.APPLICATION_JSON); ObjectMapper objectMapper
|
* helper.updateInboundLogFailure(inboundLog, e.getMessage(), "INTERRUPTED");
|
||||||
* = new ObjectMapper();
|
* throw new CustomException("Thread interrupted during transaction check"); } }
|
||||||
*
|
* }
|
||||||
* OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId,
|
*
|
||||||
* apiName, url, "GET", null);
|
*
|
||||||
*
|
*/
|
||||||
* long startTime = System.currentTimeMillis(); long maxWaitTimeMs = 40000; long
|
|
||||||
* intervalMs = 5000;
|
|
||||||
*
|
|
||||||
* while (true) { Map<String, String> responseMap = httpService.getRequest(url,
|
|
||||||
* headers); String responseData = responseMap.get("data");
|
|
||||||
* LOGGER.info("Transaction status response: {}", responseData);
|
|
||||||
*
|
|
||||||
* helper.updateOutboundLogResponse(outboundLog, responseData);
|
|
||||||
*
|
|
||||||
* try { Map<String, Object> dataMap = objectMapper.readValue(responseData, new
|
|
||||||
* TypeReference<Map<String, Object>>() {});
|
|
||||||
*
|
|
||||||
* if (!dataMap.containsKey("generalResp")) {
|
|
||||||
* helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
|
||||||
* throw new CustomException( String.valueOf(dataMap.get("message")),
|
|
||||||
* String.valueOf(dataMap.get("status")),
|
|
||||||
* Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
|
||||||
* String.valueOf(dataMap.get("remarks")) ); }
|
|
||||||
*
|
|
||||||
* TransactionStatusResponse responseWrapper =
|
|
||||||
* objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
|
|
||||||
* GeneralResp generalResp = responseWrapper.getGeneralResp();
|
|
||||||
*
|
|
||||||
* String status = generalResp.getStatus();
|
|
||||||
* LOGGER.info("Current transaction status: {}", status);
|
|
||||||
*
|
|
||||||
* if ("INPROGRESS".equalsIgnoreCase(status)) { if (System.currentTimeMillis() -
|
|
||||||
* startTime > maxWaitTimeMs) { helper.updateInboundLogFailure(inboundLog,
|
|
||||||
* "Timeout after 40 seconds", "FAILED"); throw new
|
|
||||||
* CustomException("Timeout waiting for transaction completion", "FAILED", 408,
|
|
||||||
* "Transaction still in progress"); }
|
|
||||||
*
|
|
||||||
* Thread.sleep(intervalMs); continue; }
|
|
||||||
*
|
|
||||||
* ResponseModel responseModel = new ResponseModel( generalResp.getMessage(),
|
|
||||||
* generalResp.getStatus(), Integer.parseInt(generalResp.getStatusCode()),
|
|
||||||
* responseWrapper );
|
|
||||||
*
|
|
||||||
* helper.updateInboundLogSuccess(inboundLog, responseData,
|
|
||||||
* generalResp.getStatus()); return responseModel;
|
|
||||||
*
|
|
||||||
* } catch (JsonProcessingException e) {
|
|
||||||
* LOGGER.error("Error parsing transaction status JSON: {}", e.getMessage());
|
|
||||||
* helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
|
||||||
* throw new CustomException("Invalid JSON received from API"); } catch
|
|
||||||
* (InterruptedException e) { Thread.currentThread().interrupt();
|
|
||||||
* helper.updateInboundLogFailure(inboundLog, e.getMessage(), "INTERRUPTED");
|
|
||||||
* throw new CustomException("Thread interrupted during transaction check"); } }
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@@ -39,9 +39,13 @@ public class BBPSConstant {
|
|||||||
public static final String CUSTOMPARAM_URL = "/customerParam?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_INTI = "/couapp/bills/fetch";
|
||||||
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 BILL_FETCH_BY_CLIENT_REQ_ID = "/couapp/bills/fetch/byClientId?clientReqId=";
|
||||||
|
public static final String BILL_VALIDATE_BY_CLIENT_REQ_ID = "/couapp/bills/validate/byClientId?clientReqId=";
|
||||||
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 CHECK_TRANSACTION_BY_CLIENT_URL = "/bills/fetch/byClientId?clientReqId=";
|
public static final String CHECK_TRANSACTION_BY_CLIENT_URL = "/bills/fetch/byClientId?clientReqId=";
|
||||||
|
public static final String CHECK_TRANSACTION_BY_CLIENT_REQ_ID_URL = "/transactions/payment/byClientId?clientReqId=";
|
||||||
public static final String DISPOSTION_URL = "/disposition";
|
public static final String DISPOSTION_URL = "/disposition";
|
||||||
public static final String TICKET_DISPOSTION_URL = "/ticket-disposition";
|
public static final String TICKET_DISPOSTION_URL = "/ticket-disposition";
|
||||||
public static final String COMPALINT_STATUS = "/couapp/ticket/status";
|
public static final String COMPALINT_STATUS = "/couapp/ticket/status";
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import com.billpaymentservice.bbps.dto.response.ComplaintHistoryStatusResponse;
|
|||||||
import com.billpaymentservice.bbps.dto.response.PlanResponse;
|
import com.billpaymentservice.bbps.dto.response.PlanResponse;
|
||||||
import com.billpaymentservice.bbps.dto.response.TicketCheckStatusResponse;
|
import com.billpaymentservice.bbps.dto.response.TicketCheckStatusResponse;
|
||||||
import com.billpaymentservice.bbps.dto.response.ViewAllComplaintsTicketsResponse;
|
import com.billpaymentservice.bbps.dto.response.ViewAllComplaintsTicketsResponse;
|
||||||
|
import com.billpaymentservice.bbps.dto.response.ViewAllComplaintsResponse;
|
||||||
import com.billpaymentservice.bbps.dto.response.ViewComplainByIdResponse;
|
import com.billpaymentservice.bbps.dto.response.ViewComplainByIdResponse;
|
||||||
import com.billpaymentservice.bbps.entites.AdditionalInfoPlans;
|
import com.billpaymentservice.bbps.entites.AdditionalInfoPlans;
|
||||||
import com.billpaymentservice.bbps.entites.AmountOptionByBillerId;
|
import com.billpaymentservice.bbps.entites.AmountOptionByBillerId;
|
||||||
@@ -616,10 +617,30 @@ public class BillerMapperHelper {
|
|||||||
return "SUCCESS";
|
return "SUCCESS";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String saveAllComplaints(ViewAllComplaintsResponse responseWrapper, String reqId, String txnId) {
|
||||||
|
|
||||||
|
ModelMapper mapper = new ModelMapper();
|
||||||
|
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||||
|
|
||||||
|
// Map list → ComplaintStatusDetails list
|
||||||
|
List<ComplaintStatusDetails> entityList = responseWrapper.getComplaintsList().stream()
|
||||||
|
.map(c -> mapper.map(c, ComplaintStatusDetails.class)).collect(Collectors.toList());
|
||||||
|
|
||||||
|
// Set extra fields
|
||||||
|
for (ComplaintStatusDetails entity : entityList) {
|
||||||
|
entity.setReqId(reqId);
|
||||||
|
entity.setTxnId(txnId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save to repository
|
||||||
|
complainDetailRepository.saveAll(entityList);
|
||||||
|
|
||||||
|
return "SUCCESS";
|
||||||
|
}
|
||||||
|
|
||||||
// Payment Data Service Impl
|
// Payment Data Service Impl
|
||||||
public ClientReqIdResponse storeClientReqIdResponse(ClientReqIdResponse responseWrapper, String reqId,
|
public ClientReqIdResponse storeClientReqIdResponse(ClientReqIdResponse responseWrapper, String reqId,
|
||||||
String txnId) {
|
String txnId) {
|
||||||
|
|
||||||
// 1. Save Parent (bill_id is PK)
|
// 1. Save Parent (bill_id is PK)
|
||||||
CheckClientStatusReqId parent = new CheckClientStatusReqId();
|
CheckClientStatusReqId parent = new CheckClientStatusReqId();
|
||||||
parent.setBillId(responseWrapper.getBillId());
|
parent.setBillId(responseWrapper.getBillId());
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.billpaymentservice.bbps.util;
|
package com.billpaymentservice.bbps.util;
|
||||||
|
|
||||||
|
import com.billpaymentservice.bbps.dto.request.FetchBillRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.sentRequest.FetchBillForwardRequest;
|
||||||
import com.billpaymentservice.bbps.entites.BillerDetails;
|
import com.billpaymentservice.bbps.entites.BillerDetails;
|
||||||
import com.billpaymentservice.bbps.entites.BillerResponseParams;
|
import com.billpaymentservice.bbps.entites.BillerResponseParams;
|
||||||
import com.billpaymentservice.bbps.entites.InterchangeFee;
|
import com.billpaymentservice.bbps.entites.InterchangeFee;
|
||||||
@@ -35,6 +37,7 @@ public class EntityRelationshipUtil {
|
|||||||
entity.getBillerAdditionalInfos().forEach(a -> a.setBiller(entity));
|
entity.getBillerAdditionalInfos().forEach(a -> a.setBiller(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (entity.getInterchangeFees() != null) {
|
if (entity.getInterchangeFees() != null) {
|
||||||
for (InterchangeFee fee : entity.getInterchangeFees()) {
|
for (InterchangeFee fee : entity.getInterchangeFees()) {
|
||||||
fee.setBiller(entity);
|
fee.setBiller(entity);
|
||||||
@@ -89,5 +92,7 @@ public class EntityRelationshipUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,14 @@ import com.billpaymentservice.bbps.dto.AdditionalInfoBillDTO;
|
|||||||
import com.billpaymentservice.bbps.dto.CustomerParamDAO;
|
import com.billpaymentservice.bbps.dto.CustomerParamDAO;
|
||||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||||
import com.billpaymentservice.bbps.dto.request.BillFetchByBillIdRequest;
|
import com.billpaymentservice.bbps.dto.request.BillFetchByBillIdRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.request.FetchBillRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.request.FetchBillValidatestRequest;
|
||||||
import com.billpaymentservice.bbps.dto.response.BillDataResponse;
|
import com.billpaymentservice.bbps.dto.response.BillDataResponse;
|
||||||
import com.billpaymentservice.bbps.dto.response.FetchBillValidateResponse;
|
import com.billpaymentservice.bbps.dto.response.FetchBillValidateResponse;
|
||||||
|
import com.billpaymentservice.bbps.dto.sentRequest.BillPaymentForwardRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.sentRequest.FetchBillForwardRequest;
|
||||||
|
import com.billpaymentservice.bbps.dto.sentRequest.FetchBillValidatestForwardRequest;
|
||||||
import com.billpaymentservice.bbps.entites.AdditionalInfoBill;
|
import com.billpaymentservice.bbps.entites.AdditionalInfoBill;
|
||||||
import com.billpaymentservice.bbps.entites.BBPSMastersData;
|
import com.billpaymentservice.bbps.entites.BBPSMastersData;
|
||||||
import com.billpaymentservice.bbps.entites.BillMaster;
|
import com.billpaymentservice.bbps.entites.BillMaster;
|
||||||
@@ -204,6 +210,7 @@ public class Helper {
|
|||||||
outboundLog.setResponsePayload(responsePayload);
|
outboundLog.setResponsePayload(responsePayload);
|
||||||
outboundLog.setResponseReceiveTime(LocalDateTime.now());
|
outboundLog.setResponseReceiveTime(LocalDateTime.now());
|
||||||
outboundTraceLogRepository.save(outboundLog);
|
outboundTraceLogRepository.save(outboundLog);
|
||||||
|
|
||||||
}
|
}
|
||||||
/* ---------- End helpers ---------- */
|
/* ---------- End helpers ---------- */
|
||||||
public void saveOrUpdateBillerData(BillerDetails newEntity) {
|
public void saveOrUpdateBillerData(BillerDetails newEntity) {
|
||||||
@@ -244,20 +251,20 @@ public class Helper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveOrUpdateBillerData(BillDataResponse responseWrapper,
|
public void saveOrUpdateBillData(BillDataResponse responseWrapper,
|
||||||
BillFetchByBillIdRequest billFetchByBillIdRequest) {
|
BillFetchByBillIdRequest billFetchByBillIdRequest,String txnId) {
|
||||||
|
|
||||||
|
|
||||||
BillMaster billMaster = new BillMaster();
|
BillMaster billMaster = new BillMaster();
|
||||||
|
|
||||||
billMaster.setBillId("12333333hjsdfjsfdj");
|
billMaster.setBillId(billFetchByBillIdRequest.getBillId());
|
||||||
billMaster.setRefId(responseWrapper.getRefId());
|
billMaster.setRefId(responseWrapper.getRefId());
|
||||||
billMaster.setBillerId(responseWrapper.getBillerId());
|
billMaster.setBillerId(responseWrapper.getBillerId());
|
||||||
billMaster.setStatus(responseWrapper.getStatus());
|
billMaster.setStatus(responseWrapper.getStatus());
|
||||||
billMaster.setActionType(responseWrapper.getActionType());
|
billMaster.setActionType(responseWrapper.getActionType());
|
||||||
billMaster.setUserId(responseWrapper.getUserId());
|
billMaster.setUserId(responseWrapper.getUserId());
|
||||||
billMaster.setReqId(billFetchByBillIdRequest.getReqId());
|
billMaster.setReqId(billFetchByBillIdRequest.getReqId());
|
||||||
billMaster.setTxnId("jhnjhbhj");
|
billMaster.setTxnId(txnId);
|
||||||
|
|
||||||
|
|
||||||
// BILLER RESPONSE
|
// BILLER RESPONSE
|
||||||
@@ -354,4 +361,65 @@ billMasterRepository.save(billMaster);
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FetchBillForwardRequest fetchBillForwardRequestMap(FetchBillRequest req) {
|
||||||
|
|
||||||
|
FetchBillForwardRequest forward = new FetchBillForwardRequest();
|
||||||
|
|
||||||
|
forward.setBillerId(req.getBillerId());
|
||||||
|
forward.setBillerName(req.getBillerName());
|
||||||
|
forward.setBillerCategory(req.getBillerCategory());
|
||||||
|
forward.setClientReqId(req.getClientReqId());
|
||||||
|
forward.setMacAdress(req.getMacAdress());
|
||||||
|
forward.setCustomerMobNo(req.getCustomerMobNo());
|
||||||
|
forward.setRemitterName(req.getRemitterName());
|
||||||
|
forward.setPaymentChannel(req.getPaymentChannel());
|
||||||
|
forward.setDeviceBlockTags(req.getDeviceBlockTags());
|
||||||
|
forward.setCustomerParamsRequest(req.getCustomerParamsRequest());
|
||||||
|
forward.setRemitterIdentity(req.getRemitterIdentity());
|
||||||
|
|
||||||
|
return forward;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FetchBillValidatestForwardRequest fetchBillValidatestForwardRequest(FetchBillValidatestRequest req) {
|
||||||
|
|
||||||
|
FetchBillValidatestForwardRequest forward = new FetchBillValidatestForwardRequest();
|
||||||
|
|
||||||
|
forward.setBillerId(req.getBillerId());
|
||||||
|
forward.setBillerName(req.getBillerName());
|
||||||
|
forward.setBillerCategory(req.getBillerCategory());
|
||||||
|
forward.setCustomerMobNo(req.getCustomerMobNo());
|
||||||
|
forward.setClientReqId(req.getClientReqId());
|
||||||
|
forward.setMacAddress(req.getMacAddress());
|
||||||
|
forward.setCustomerParamsRequest(req.getCustomerParamsRequest());
|
||||||
|
|
||||||
|
return forward;
|
||||||
|
}
|
||||||
|
public BillPaymentForwardRequest billPaymentForwardRequest(BillPaymentRequest req) {
|
||||||
|
|
||||||
|
BillPaymentForwardRequest forward = new BillPaymentForwardRequest();
|
||||||
|
|
||||||
|
forward.setTenantId(req.getTenantId());
|
||||||
|
forward.setRefId(req.getRefId());
|
||||||
|
forward.setBillId(req.getBillId());
|
||||||
|
forward.setAmountOptions(req.isAmountOptions());
|
||||||
|
forward.setPaymentMode(req.getPaymentMode());
|
||||||
|
forward.setPaymentInformation(req.getPaymentInformation());
|
||||||
|
forward.setBillerId(req.getBillerId());
|
||||||
|
forward.setBillerName(req.getBillerName());
|
||||||
|
forward.setBillerCategory(req.getBillerCategory());
|
||||||
|
forward.setMacAdress(req.getMacAdress());
|
||||||
|
forward.setCustomerMobNo(req.getCustomerMobNo());
|
||||||
|
forward.setTxnAmount(req.getTxnAmount());
|
||||||
|
forward.setPaymentRefId(req.getPaymentRefId());
|
||||||
|
forward.setClientReqId(req.getClientReqId());
|
||||||
|
forward.setPaymentChannel(req.getPaymentChannel());
|
||||||
|
|
||||||
|
forward.setDeviceBlockTags(req.getDeviceBlockTags());
|
||||||
|
forward.setCustomerParamsRequest(req.getCustomerParamsRequest());
|
||||||
|
forward.setRemitterIdentity(req.getRemitterIdentity());
|
||||||
|
forward.setAmountBreakSet(req.getAmountBreakSet());
|
||||||
|
|
||||||
|
return forward;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user