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.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.FetchBillValidatestRequest;
|
||||
import com.billpaymentservice.bbps.service.AgentService;
|
||||
@@ -68,5 +70,21 @@ public class AgentController {
|
||||
ResponseModel response = agentService.initiateBillValidateByBillId(billRequest);
|
||||
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.ComplaintRequestDTO;
|
||||
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.service.ComplainService;
|
||||
|
||||
@@ -33,7 +35,7 @@ public class ComplainController {
|
||||
public ComplainController(ComplainService complainService) {
|
||||
this.complainService = complainService;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/addComplainTicket", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> addComplain(@Validated @RequestBody ComplaintRequestDTO complainRequestDTO) {
|
||||
|
||||
@@ -42,7 +44,8 @@ public class ComplainController {
|
||||
}
|
||||
|
||||
@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());
|
||||
ResponseModel response = complainService.getComplaintStatus(request);
|
||||
return ResponseEntity.ok(response);
|
||||
@@ -61,12 +64,12 @@ public class ComplainController {
|
||||
ResponseModel response = complainService.viewComplaintById(request);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/allMasterOptions")
|
||||
public ResponseEntity<ResponseModel> getAllStatuses(@Validated @RequestBody AllMasterOptionsRequest request) {
|
||||
return ResponseEntity.ok(complainService.getAllActiveStatuses(request));
|
||||
return ResponseEntity.ok(complainService.getAllActiveStatuses(request));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/viewAllComplaints")
|
||||
public ResponseEntity<ResponseModel> viewAllComplaints(@RequestBody ViewAllComplaintsTicketsRequest request) {
|
||||
log.info("Received request complaint View All Complaints for Status Type={}", request.getStatusType());
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.TransactionStatusRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.TrasactionStatusByClientReqIdRequest;
|
||||
import com.billpaymentservice.bbps.service.PaymentService;
|
||||
|
||||
@RestController
|
||||
@@ -43,6 +44,12 @@ public class PaymentController {
|
||||
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.JsonIgnoreProperties;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class ComplainDetailsDto {
|
||||
|
||||
@JsonProperty("TicketId")
|
||||
|
||||
@@ -20,49 +20,35 @@ import lombok.ToString;
|
||||
public abstract class BaseClass {
|
||||
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
@NotBlank(message = "MID cannot be null or blank")
|
||||
private String mid;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
|
||||
@NotBlank(message = "Secret key cannot be null or blank")
|
||||
private String secretKey;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
@NotBlank(message = "Request ID cannot be null or blank")
|
||||
private String reqId;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private DeviceDetail deviceDetial;
|
||||
// ✅ 10 User Defined Fields (UDF1–UDF10)
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private String udf1;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private String udf2;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private String udf3;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private String udf4;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private String udf5;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private String udf6;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private String udf7;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private String udf8;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private String udf9;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
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 Integer txnAmount;
|
||||
private String paymentRefId;
|
||||
private String clientReqId;
|
||||
private String paymentChannel;
|
||||
|
||||
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
|
||||
@NotNull
|
||||
private String customerMobNo; // String, Mobile of the Customer
|
||||
private String clientReqId;
|
||||
|
||||
// Optional Fields
|
||||
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.ViewComplaintDTO;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class ViewComplainByIdResponse {
|
||||
private List<ViewComplaintDTO> tickets;
|
||||
@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
|
||||
@Setter
|
||||
@Entity
|
||||
@ToString
|
||||
@ToString(exclude = {
|
||||
"billerPaymentModes",
|
||||
"billerPaymentChannels",
|
||||
"billerCustomerParams",
|
||||
"customerParamGroups",
|
||||
"billerResponseParams",
|
||||
"billerAdditionalInfos",
|
||||
"interchangeFeeConves",
|
||||
"interchangeFees",
|
||||
"billerPlanResponseParams"
|
||||
})
|
||||
|
||||
@Table(name = "biller_details")
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class BillerDetails {
|
||||
@@ -140,10 +151,12 @@ public class BillerDetails {
|
||||
@OneToMany(mappedBy = "biller", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
private List<AdditionalInfo> billerAdditionalInfos;
|
||||
|
||||
|
||||
/*
|
||||
* @OneToMany(mappedBy = "biller", cascade = CascadeType.ALL, orphanRemoval =
|
||||
* true) private List<AdditionalInfo> billerAdditionalInfoPayments;
|
||||
*/
|
||||
* OneToMany(mappedBy = "biller", cascade = CascadeType.ALL, orphanRemoval
|
||||
* =true) private List<AdditionalInfo> billerAdditionalInfoPayments;
|
||||
*/
|
||||
|
||||
@OneToMany(mappedBy = "biller", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
private List<InterchangeFeeConf> interchangeFeeConves;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ComplaintStatusDetails extends Auditable<String>{
|
||||
|
||||
@Column(name = "txn_id")
|
||||
private String systemTxnId;
|
||||
|
||||
|
||||
@Column(name = "total_elements")
|
||||
private String totalElements;
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.billpaymentservice.bbps.repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -8,4 +10,8 @@ import com.billpaymentservice.bbps.entites.BillInitiate;
|
||||
@Repository
|
||||
public interface BillInitateRepository extends JpaRepository<BillInitiate, String> {
|
||||
|
||||
Optional<BillInitiate> findByTxnId(String clientReqId);
|
||||
|
||||
Optional<BillInitiate> findByReqId(String clientReqId);
|
||||
|
||||
}
|
||||
|
||||
@@ -5,11 +5,10 @@ import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.billpaymentservice.bbps.entites.BillerDetails;
|
||||
|
||||
@Repository
|
||||
public interface BillerDataRepository extends JpaRepository<BillerDetails, String> {
|
||||
|
||||
|
||||
Optional<BillerDetails> findByBillerId(String billerId);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package com.billpaymentservice.bbps.repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import com.billpaymentservice.bbps.entites.PaymentInitiate;
|
||||
|
||||
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.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.FetchBillValidatestRequest;
|
||||
|
||||
public interface AgentService {
|
||||
|
||||
ResponseModel initiateBillFetch(FetchBillRequest fetchBillRequest);
|
||||
|
||||
public ResponseModel initiateBillFetch(FetchBillRequest fetchBillRequest);
|
||||
ResponseModel fetchBillById(BillFetchByBillIdRequest billFetchByBillIdRequest);
|
||||
|
||||
public ResponseModel fetchBillById(BillFetchByBillIdRequest billFetchByBillIdRequest);
|
||||
ResponseModel initiateBillValidate(FetchBillValidatestRequest fetchBillValidateRequest);
|
||||
|
||||
public ResponseModel initiateBillValidate(FetchBillValidatestRequest fetchBillValidateRequest);
|
||||
ResponseModel initiateBillValidateByBillId(BillFetchByBillIdRequest billRequest);
|
||||
|
||||
public 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.request.AllMasterOptionsRequest;
|
||||
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.GetTicketLatestStausRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.TxnStatusRequest;
|
||||
@@ -22,6 +25,7 @@ public interface ComplainService {
|
||||
|
||||
ResponseModel checkTxnStatus(TxnStatusRequest request);
|
||||
|
||||
|
||||
ResponseModel ViewAllComplaints(ViewAllComplaintsTicketsRequest request);
|
||||
|
||||
}
|
||||
|
||||
@@ -3,12 +3,14 @@ package com.billpaymentservice.bbps.service;
|
||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.TransactionStatusRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.TrasactionStatusByClientReqIdRequest;
|
||||
|
||||
public interface PaymentService {
|
||||
|
||||
|
||||
public ResponseModel initiatePayment(BillPaymentRequest billPaymentRequest);
|
||||
|
||||
|
||||
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest);
|
||||
|
||||
ResponseModel checkTrasactionStatusByClientReqId(TrasactionStatusByClientReqIdRequest transactionStatusRequest);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.billpaymentservice.bbps.serviceImpl;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
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.ResponseModel;
|
||||
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.FetchBillValidatestRequest;
|
||||
import com.billpaymentservice.bbps.dto.response.BillDataResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.FetchBillResponse;
|
||||
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.BillInitiate;
|
||||
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.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Service
|
||||
@@ -54,7 +58,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
private final BillMasterRepository billMasterRepository;
|
||||
private final BillInitateRepository billIntiateRepository;
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AgentServiceImpl.class);
|
||||
|
||||
|
||||
public AgentServiceImpl(RestClient restClient, HttpService httpService, Helper helper,
|
||||
BharatConnectMasterRepository beneficiaryDetailsRepository,
|
||||
InboundTraceLogRepository inboundTraceLogRepository, OutboundTraceLogRepository outboundTraceLogRepository,
|
||||
@@ -77,7 +81,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String requestId = fetchBillRequest.getReqId();
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_INTI;
|
||||
|
||||
fetchBillRequest.setClientReqId(txnId);
|
||||
helper.validateMerchant(fetchBillRequest.getMid());
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
@@ -89,18 +93,21 @@ public class AgentServiceImpl implements AgentService {
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
FetchBillForwardRequest forwardReq = helper.fetchBillForwardRequestMap(fetchBillRequest);
|
||||
|
||||
String forwardJson = helper.convertObjectToJson(forwardReq);
|
||||
String requestJson = helper.convertObjectToJson(fetchBillRequest);
|
||||
|
||||
// ✅ Create inbound & outbound logs
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, fetchBillRequest.getMid(),
|
||||
"POST", requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, fullUrl, "POST",
|
||||
requestJson);
|
||||
forwardJson);
|
||||
LOGGER.debug("Outbound log created successfully for txnId: {} and reqId: {}", txnId, requestId);
|
||||
|
||||
try {
|
||||
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");
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
@@ -163,9 +170,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
String reqId = billFetchByBillIdRequest.getReqId();
|
||||
String billId = billFetchByBillIdRequest.getBillId();
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + billFetchByBillIdRequest.getBillId();
|
||||
|
||||
helper.validateMerchant(billFetchByBillIdRequest.getMid());
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
@@ -204,7 +209,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
LOGGER.info("Current Bill Status: {}", status);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
helper.saveOrUpdateBillerData(responseWrapper, billFetchByBillIdRequest);
|
||||
helper.saveOrUpdateBillData(responseWrapper, billFetchByBillIdRequest, txnId);
|
||||
LOGGER.info("Bill data saved successfully for billId: {}", billId);
|
||||
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
@@ -222,7 +227,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = billFetchByBillIdRequest.getReqId();
|
||||
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);
|
||||
|
||||
@@ -260,7 +265,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
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());
|
||||
|
||||
return responseModel;
|
||||
@@ -274,14 +279,13 @@ public class AgentServiceImpl implements AgentService {
|
||||
@Override
|
||||
public ResponseModel initiateBillValidate(FetchBillValidatestRequest fetchBillValidateRequest) {
|
||||
|
||||
|
||||
LOGGER.info("Initiating bill Validate for request ID: {} and MID", fetchBillValidateRequest.getReqId(),
|
||||
fetchBillValidateRequest.getMid());
|
||||
String apiName = "InitiateBillValidate";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = fetchBillValidateRequest.getReqId();
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILLER_VALIDATE_URL;
|
||||
|
||||
fetchBillValidateRequest.setClientReqId(txnId);
|
||||
helper.validateMerchant(fetchBillValidateRequest.getMid());
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
@@ -293,25 +297,27 @@ public class AgentServiceImpl implements AgentService {
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
FetchBillValidatestForwardRequest forwardReq = helper
|
||||
.fetchBillValidatestForwardRequest(fetchBillValidateRequest);
|
||||
|
||||
String forwardJson = helper.convertObjectToJson(forwardReq);
|
||||
|
||||
String requestJson = helper.convertObjectToJson(fetchBillValidateRequest);
|
||||
|
||||
// ✅ Create inbound & outbound logs
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, fetchBillValidateRequest.getMid(),
|
||||
"POST", requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "POST",
|
||||
requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "POST", forwardJson);
|
||||
LOGGER.debug("Outbound log created successfully for txnId: {} and reqId: {}", txnId, reqId);
|
||||
|
||||
try {
|
||||
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");
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
LOGGER.debug("Response received from BBPS: {}", responseData);
|
||||
|
||||
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
@@ -329,7 +335,6 @@ public class AgentServiceImpl implements AgentService {
|
||||
billMaster.setTxnId(txnId);
|
||||
billMasterRepository.save(billMaster);
|
||||
LOGGER.info("BillMaster saved for billId: {}", billMaster.getBillId());
|
||||
|
||||
FetchBillResponse fetchBillResponse = objectMapper.convertValue(dataMap, FetchBillResponse.class);
|
||||
GeneralResp generalResponse = fetchBillResponse.getGenericResponse();
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResponse.getStatus());
|
||||
@@ -360,79 +365,208 @@ public class AgentServiceImpl implements AgentService {
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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(); ;
|
||||
// ================================== Bill fetch and Bill Validate by Client Req
|
||||
// Id==================================//
|
||||
|
||||
helper.validateMerchant(billRequest.getMid());
|
||||
@Override
|
||||
public ResponseModel fetchBillValidateByClientReqId(BillValidateByClientIdRequest billValidateByClientIdRequest) {
|
||||
|
||||
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);
|
||||
String apiName = "FetchBillValidateByClientIdRequest";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = billValidateByClientIdRequest.getReqId();
|
||||
String clientReqId = billValidateByClientIdRequest.getClientReqId();
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||
LOGGER.debug("Outbound log created successfully for FetchBillById: {}", fullUrl);
|
||||
Optional<BillInitiate> billInitiate = billIntiateRepository.findByReqId(clientReqId);
|
||||
if (billInitiate.isEmpty()) {
|
||||
throw new CustomException("No Bill Found for given Client Req Id");
|
||||
}
|
||||
|
||||
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);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_VALIDATE_BY_CLIENT_REQ_ID + billInitiate.get().getTxnId();
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
helper.validateMerchant(billValidateByClientIdRequest.getMid());
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
|
||||
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);
|
||||
|
||||
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"))
|
||||
);
|
||||
}
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
FetchBillValidateResponse responseWrapper = objectMapper.convertValue(dataMap, FetchBillValidateResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||
// 🔵 Create Inbound + Outbound Logs
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName,
|
||||
billValidateByClientIdRequest.getMid(), "GET", null);
|
||||
|
||||
String status = generalResp.getStatus();
|
||||
LOGGER.info("Current Bill Status: {}", status);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
System.out.println("responseWrapper:"+responseWrapper);
|
||||
helper.saveBillValidation(responseWrapper,billRequest);
|
||||
LOGGER.info("Bill data saved successfully for billId: {}", billId);
|
||||
try {
|
||||
LOGGER.info("Calling BBPS API FetchBillValidateByClientReqId, URL={}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
}}
|
||||
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")));
|
||||
}
|
||||
|
||||
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
|
||||
@@ -621,11 +755,9 @@ public class AgentServiceImpl implements AgentService {
|
||||
* }
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ResponseModel initiateBillValidateByBillId(BillFetchByBillIdRequest billRequest) {
|
||||
// TODO Auto-generated method stub
|
||||
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.TxnStatusRequest;
|
||||
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.ComplaintResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.TicketCheckStatusResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.TxnStatusResponse;
|
||||
|
||||
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.entites.BharatConnectMaster;
|
||||
import com.billpaymentservice.bbps.entites.ComplaintStatusOptionsMaster;
|
||||
@@ -538,9 +542,8 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
String status = generalResp.getStatus();
|
||||
LOGGER.info("Current Complaint ReOpen Status: {}", status);
|
||||
|
||||
String saveComplaint = mapperHelper.saveAllComplaints(responseWrapper, reqId, txnId);
|
||||
LOGGER.info("Complaint ReOpen data saved successfully for Count History: {}",
|
||||
saveComplaint);
|
||||
String saveComplaint = mapperHelper.saveAllComplaints(responseWrapper, reqId, txnId);
|
||||
LOGGER.info("Complaint ReOpen data saved successfully for Count History: {}", saveComplaint);
|
||||
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
@@ -173,6 +173,8 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
String requestJson = helper.convertObjectToJson(billerDetailRequest);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, billerDetailRequest.getMid(),
|
||||
"POST", requestJson);
|
||||
|
||||
System.out.println( billerDataRespository.findByBillerId(billerId));
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
||||
LOGGER.info("Calling external API: {}", 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,
|
||||
BBPSConstant.BILLER_URL, masterRequest.getBillerName(), masterRequest.getCategory(),
|
||||
masterRequest.getPageNo(), masterRequest.getPageSize());
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.billpaymentservice.bbps.serviceImpl;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.modelmapper.ModelMapper;
|
||||
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.MediaType;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
|
||||
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.ClientReqIdResponse;
|
||||
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.BharatConnectMaster;
|
||||
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.service.PaymentService;
|
||||
import com.billpaymentservice.bbps.util.BBPSConstant;
|
||||
import com.billpaymentservice.bbps.util.BillerMapperHelper;
|
||||
import com.billpaymentservice.bbps.util.EntityRelationshipUtil;
|
||||
import com.billpaymentservice.bbps.util.Helper;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
@@ -58,7 +58,6 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
private final PaymentIntiateRepository paymentIntiateRepository;
|
||||
private final TransactionMasterRepository transactionMasterRepository;
|
||||
private final AgentFundTransferRepository agentFundTransferRepository;
|
||||
private final BillerMapperHelper mapperHelper;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PaymentServiceImpl.class);
|
||||
|
||||
@@ -66,7 +65,7 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
Helper helper, PaymentRepository paymentRepository, InboundTraceLogRepository inboundTraceLogRepository,
|
||||
OutboundTraceLogRepository outboundTraceLogRepository, PaymentIntiateRepository paymentIntiateRepository,
|
||||
TransactionMasterRepository transactionMasterRepository,
|
||||
AgentFundTransferRepository agentFundTransferRepository, BillerMapperHelper mapperHelper) {
|
||||
AgentFundTransferRepository agentFundTransferRepository) {
|
||||
this.beneficiaryDetailsRepository = beneficiaryDetailsRepository;
|
||||
this.httpService = httpService;
|
||||
this.helper = helper;
|
||||
@@ -76,167 +75,170 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
this.paymentIntiateRepository = paymentIntiateRepository;
|
||||
this.transactionMasterRepository = transactionMasterRepository;
|
||||
this.agentFundTransferRepository = agentFundTransferRepository;
|
||||
this.mapperHelper = mapperHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel initiatePayment(BillPaymentRequest billPaymentRequest) {
|
||||
String apiName = "InitiatePayment";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String requestId = billPaymentRequest.getReqId();
|
||||
String url = paymentUrl + BBPSConstant.PAYMENT_URL;
|
||||
String apiName = "InitiatePayment";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String requestId = billPaymentRequest.getReqId();
|
||||
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");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
BillPaymentForwardRequest forwardReq =
|
||||
helper.billPaymentForwardRequest(billPaymentRequest);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
String forwardjson = helper.convertObjectToJson(forwardReq);
|
||||
|
||||
String requestJson = helper.convertObjectToJson(billPaymentRequest);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, billPaymentRequest.getMid(),
|
||||
"POST", requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, "POST", requestJson);
|
||||
String requestJson = helper.convertObjectToJson(billPaymentRequest);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling BBPS payment URL: {}", url);
|
||||
Map<String, String> responseMap = httpService.postRequest(url, requestJson, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("Payment API Response: {}", responseData);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, billPaymentRequest.getMid(), "POST", requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, "POST",forwardjson);
|
||||
|
||||
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.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");
|
||||
}
|
||||
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_STRUCTURE");
|
||||
LOGGER.warn("Invalid response structure received for txnId={}", txnId);
|
||||
throw new CustomException("Invalid response structure from BBPS");
|
||||
}
|
||||
if (responseData == null || responseData.isEmpty()) {
|
||||
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");
|
||||
}
|
||||
|
||||
BillPaymentResponse billPaymentResponse = objectMapper.convertValue(dataMap, BillPaymentResponse.class);
|
||||
GeneralResp generalResponse = billPaymentResponse.getGenericResponse();
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
|
||||
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();
|
||||
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||
BillPayment entity = mapper.map(billPaymentResponse, BillPayment.class);
|
||||
paymentRepository.save(entity);
|
||||
LOGGER.info("BillPayment entity saved successfully for txnId={}", txnId);
|
||||
BillPaymentResponse billPaymentResponse = objectMapper.convertValue(dataMap, BillPaymentResponse.class);
|
||||
GeneralResp generalResponse = billPaymentResponse.getGenericResponse();
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResponse.getStatus());
|
||||
PaymentInitiate paymentInitiate = new PaymentInitiate();
|
||||
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);
|
||||
ModelMapper mapper = new ModelMapper();
|
||||
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||
BillPayment entity = mapper.map(billPaymentResponse, BillPayment.class);
|
||||
paymentRepository.save(entity);
|
||||
LOGGER.info("BillPayment entity saved successfully for txnId={}", txnId);
|
||||
|
||||
TransactionStatusRequest transactionStatusRequest = new TransactionStatusRequest();
|
||||
transactionStatusRequest.setTxnId(billPaymentResponse.getTxnId());
|
||||
transactionStatusRequest.setReqId(requestId);
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResponse.getStatus());
|
||||
PaymentInitiate paymentInitiate = new PaymentInitiate();
|
||||
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 {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
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);
|
||||
TransactionStatusRequest transactionStatusRequest = new TransactionStatusRequest();
|
||||
transactionStatusRequest.setTxnId(billPaymentResponse.getTxnId());
|
||||
transactionStatusRequest.setReqId(requestId);
|
||||
|
||||
try {
|
||||
Thread.sleep(9000);
|
||||
} catch (InterruptedException e) {
|
||||
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");
|
||||
}
|
||||
} 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,
|
||||
InboundTraceLog inboundLog) {
|
||||
String apiName = "CheckTransactionStatus";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String requestId = transactionStatusRequest.getReqId();
|
||||
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
|
||||
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest, InboundTraceLog inboundLog) {
|
||||
String apiName = "CheckTransactionStatus";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
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);
|
||||
LOGGER.info("Checking transaction status (internal) for txnId={} and reqId={}", transactionStatusRequest.getTxnId(), requestId);
|
||||
|
||||
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");
|
||||
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, requestId, apiName, url, "GET", null);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, "GET", null);
|
||||
|
||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("Transaction status response: {}", responseData);
|
||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("Transaction status response: {}", responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, 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");
|
||||
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")));
|
||||
}
|
||||
try {
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
|
||||
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,
|
||||
TransactionStatusResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
LOGGER.info("Transaction status received: {}", generalResp.getStatus());
|
||||
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
LOGGER.info("Transaction status received: {}", generalResp.getStatus());
|
||||
|
||||
ModelMapper mapper = new ModelMapper();
|
||||
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);
|
||||
ModelMapper mapper = new ModelMapper();
|
||||
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);
|
||||
|
||||
AgentFundTransfer agentFundTransfer = mapper.map(responseWrapper.getAgentFundTransfer(),
|
||||
AgentFundTransfer.class);
|
||||
agentFundTransfer.setTxnId(txnId);
|
||||
agentFundTransfer.setReqId(transactionStatusRequest.getReqId());
|
||||
agentFundTransfer.setTransactionMasterId(transactionMaster.getBankTxnId());
|
||||
agentFundTransferRepository.save(agentFundTransfer);
|
||||
LOGGER.info("AgentFundTransfer entry saved successfully for txnId={}", txnId);
|
||||
AgentFundTransfer agentFundTransfer = mapper.map(responseWrapper.getAgentFundTransfer(), AgentFundTransfer.class);
|
||||
agentFundTransfer.setTxnId(txnId);
|
||||
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(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
ResponseModel responseModel = new ResponseModel(
|
||||
generalResp.getMessage(),
|
||||
generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()),
|
||||
responseWrapper
|
||||
);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
return responseModel;
|
||||
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");
|
||||
}
|
||||
} 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
|
||||
@@ -246,184 +248,276 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
String apiName = "checkTrasactionStatus";
|
||||
String requestId = transactionStatusRequest.getReqId();
|
||||
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={}",
|
||||
transactionStatusRequest.getTxnId(), requestId);
|
||||
LOGGER.info("Checking transaction status (public) for txnId={} and reqId={}", transactionStatusRequest.getTxnId(), requestId);
|
||||
|
||||
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");
|
||||
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);
|
||||
|
||||
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();
|
||||
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();
|
||||
|
||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("Transaction status response data: {}", responseData);
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("Transaction status response data: {}", 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, String.valueOf(dataMap.get("status")));
|
||||
LOGGER.warn("Invalid transaction status response for txnId={} from BBPS",
|
||||
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")));
|
||||
}
|
||||
try {
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
||||
LOGGER.warn("Invalid transaction status response for txnId={} from BBPS", 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,
|
||||
TransactionStatusResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
|
||||
String status = generalResp.getStatus();
|
||||
LOGGER.info("Current transaction status: {}", status);
|
||||
String status = generalResp.getStatus();
|
||||
LOGGER.info("Current transaction status: {}", status);
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
ResponseModel responseModel = new ResponseModel(
|
||||
generalResp.getMessage(),
|
||||
generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()),
|
||||
responseWrapper
|
||||
);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
return responseModel;
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
return responseModel;
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
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
|
||||
*
|
||||
* @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"); }
|
||||
*
|
||||
* }
|
||||
*/
|
||||
|
||||
/*
|
||||
* public ResponseModel checkTrasactionStatus(TransactionStatusRequest
|
||||
* transactionStatusRequest,InboundTraceLog inboundLog) { String apiName =
|
||||
* "CheckTransactionStatus"; String txnId = helper.generateTxnId(15); //our
|
||||
* genrated txnId String requestId = transactionStatusRequest.getReqId(); String
|
||||
* url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL +
|
||||
* transactionStatusRequest.getTxnId(); ;
|
||||
*
|
||||
* 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, 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"); } }
|
||||
* }
|
||||
*
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* public ResponseModel checkTrasactionStatus(TransactionStatusRequest
|
||||
* transactionStatusRequest,InboundTraceLog inboundLog) { String apiName =
|
||||
* "CheckTransactionStatus"; String txnId = helper.generateTxnId(15); //our
|
||||
* genrated txnId String requestId = transactionStatusRequest.getReqId(); String
|
||||
* url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL +
|
||||
* transactionStatusRequest.getTxnId(); ;
|
||||
*
|
||||
* 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, 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 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_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 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_REQ_ID_URL = "/transactions/payment/byClientId?clientReqId=";
|
||||
public static final String DISPOSTION_URL = "/disposition";
|
||||
public static final String TICKET_DISPOSTION_URL = "/ticket-disposition";
|
||||
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.TicketCheckStatusResponse;
|
||||
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.entites.AdditionalInfoPlans;
|
||||
import com.billpaymentservice.bbps.entites.AmountOptionByBillerId;
|
||||
@@ -616,10 +617,30 @@ public class BillerMapperHelper {
|
||||
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
|
||||
public ClientReqIdResponse storeClientReqIdResponse(ClientReqIdResponse responseWrapper, String reqId,
|
||||
String txnId) {
|
||||
|
||||
// 1. Save Parent (bill_id is PK)
|
||||
CheckClientStatusReqId parent = new CheckClientStatusReqId();
|
||||
parent.setBillId(responseWrapper.getBillId());
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.billpaymentservice.bbps.util;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.request.FetchBillRequest;
|
||||
import com.billpaymentservice.bbps.dto.sentRequest.FetchBillForwardRequest;
|
||||
import com.billpaymentservice.bbps.entites.BillerDetails;
|
||||
import com.billpaymentservice.bbps.entites.BillerResponseParams;
|
||||
import com.billpaymentservice.bbps.entites.InterchangeFee;
|
||||
@@ -34,6 +36,7 @@ public class EntityRelationshipUtil {
|
||||
if (entity.getBillerAdditionalInfos() != null) {
|
||||
entity.getBillerAdditionalInfos().forEach(a -> a.setBiller(entity));
|
||||
}
|
||||
|
||||
|
||||
if (entity.getInterchangeFees() != null) {
|
||||
for (InterchangeFee fee : entity.getInterchangeFees()) {
|
||||
@@ -88,6 +91,8 @@ public class EntityRelationshipUtil {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,14 @@ import com.billpaymentservice.bbps.dto.AdditionalInfoBillDTO;
|
||||
import com.billpaymentservice.bbps.dto.CustomerParamDAO;
|
||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||
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.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.BBPSMastersData;
|
||||
import com.billpaymentservice.bbps.entites.BillMaster;
|
||||
@@ -204,6 +210,7 @@ public class Helper {
|
||||
outboundLog.setResponsePayload(responsePayload);
|
||||
outboundLog.setResponseReceiveTime(LocalDateTime.now());
|
||||
outboundTraceLogRepository.save(outboundLog);
|
||||
|
||||
}
|
||||
/* ---------- End helpers ---------- */
|
||||
public void saveOrUpdateBillerData(BillerDetails newEntity) {
|
||||
@@ -244,20 +251,20 @@ public class Helper {
|
||||
}
|
||||
}
|
||||
|
||||
public void saveOrUpdateBillerData(BillDataResponse responseWrapper,
|
||||
BillFetchByBillIdRequest billFetchByBillIdRequest) {
|
||||
public void saveOrUpdateBillData(BillDataResponse responseWrapper,
|
||||
BillFetchByBillIdRequest billFetchByBillIdRequest,String txnId) {
|
||||
|
||||
|
||||
BillMaster billMaster = new BillMaster();
|
||||
|
||||
billMaster.setBillId("12333333hjsdfjsfdj");
|
||||
billMaster.setBillId(billFetchByBillIdRequest.getBillId());
|
||||
billMaster.setRefId(responseWrapper.getRefId());
|
||||
billMaster.setBillerId(responseWrapper.getBillerId());
|
||||
billMaster.setStatus(responseWrapper.getStatus());
|
||||
billMaster.setActionType(responseWrapper.getActionType());
|
||||
billMaster.setUserId(responseWrapper.getUserId());
|
||||
billMaster.setReqId(billFetchByBillIdRequest.getReqId());
|
||||
billMaster.setTxnId("jhnjhbhj");
|
||||
billMaster.setTxnId(txnId);
|
||||
|
||||
|
||||
// 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