saved initate payment and checktxn status
This commit is contained in:
@@ -3,6 +3,7 @@ package com.billpaymentservice.bbps.dto;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
@@ -12,10 +13,10 @@ import lombok.Setter;
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
|
||||
public class TransactionDTO {
|
||||
|
||||
@NotBlank private String txnId;
|
||||
|
||||
@JsonProperty("txnId")
|
||||
@NotBlank private String bankTxnId;
|
||||
@NotBlank private String refId;
|
||||
private String txnNpciId;
|
||||
private String paymentRefId;
|
||||
@@ -55,12 +56,10 @@ public class TransactionDTO {
|
||||
private String fundTxnType;
|
||||
private String reason;
|
||||
|
||||
private List<String> amountTags;
|
||||
private List<String> customerParamsDAOS;
|
||||
private List<String> paymentInformation;
|
||||
private String amountTags;
|
||||
private String customerParamsDAOS;
|
||||
private String paymentInformation;
|
||||
private List<DeviceBlockTag> deviceBlockTags;
|
||||
|
||||
|
||||
private List<CustomerParamDAO> customerParamsDAO;
|
||||
|
||||
private String planId;
|
||||
|
||||
@@ -7,9 +7,11 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class TransactionStatusResponse {
|
||||
|
||||
@JsonProperty("transactionDAO")
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.billpaymentservice.bbps.entites;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "agent_fund_transfer_Txn_Status")
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class AgentFundTransfer {
|
||||
|
||||
|
||||
@Id
|
||||
@Column(name = "fund_txn_reference_id")
|
||||
private String fundTxnReferenceId;
|
||||
|
||||
@Column(name = "transaction_master_id")
|
||||
private String TransactionMasterId; //primary key from transaction master
|
||||
|
||||
@Column(name = "txn_id")
|
||||
private String txnId;
|
||||
@Column(name = "req_id")
|
||||
private String reqId;
|
||||
@Column(name = "fund_txn_remarks")
|
||||
private String fundTxnRemarks;
|
||||
|
||||
@Column(name = "fund_txn_date")
|
||||
private String fundTxnDate;
|
||||
|
||||
@Column(name = "fund_txn_amt")
|
||||
private Double fundTxnAmt;
|
||||
|
||||
@Column(name = "fund_utr")
|
||||
private String fundUTR;
|
||||
|
||||
@Column(name = "fund_resp_remarks")
|
||||
private String fundRespRemarks;
|
||||
|
||||
@Column(name = "agent_npci_id")
|
||||
private String agentNpciId;
|
||||
|
||||
@Column(name = "txn_ref_id")
|
||||
private String txnRefId;
|
||||
|
||||
@Column(name = "fund_status")
|
||||
private String fundStatus;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.billpaymentservice.bbps.entites;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@Table(name = "customer_params_transaction")
|
||||
public class CustomerParamTransaction {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
private String paramsId;
|
||||
private String name;
|
||||
private String value;
|
||||
private String type;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "txn_id", referencedColumnName = "bank_txn_id")
|
||||
private TransactionMaster transactionMaster;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.billpaymentservice.bbps.entites;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@Table(name = "device_block_tag")
|
||||
public class DeviceBlockTag {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "name")
|
||||
private String name;
|
||||
|
||||
@Column(name = "tag_id")
|
||||
private String tagId;
|
||||
|
||||
@Column(name = "value")
|
||||
private String value;
|
||||
|
||||
// ✅ ManyToOne relation back to TransactionMaster
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "txn_id", referencedColumnName = "bank_txn_id")
|
||||
private TransactionMaster transactionMaster;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.billpaymentservice.bbps.entites;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "payment_initiate")
|
||||
public class PaymentInitiate {
|
||||
|
||||
@Id
|
||||
@Column(name = "req_id")
|
||||
private String reqId;
|
||||
|
||||
@Column(name = "bank_txn_Id", nullable = false)
|
||||
private String bankTxnId;
|
||||
|
||||
@Column(name = "txn_id")
|
||||
private String txnId;
|
||||
|
||||
@Column(name = "status")
|
||||
private String status;
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
package com.billpaymentservice.bbps.entites;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "transaction_master")
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TransactionMaster {
|
||||
|
||||
// 👇 JSON me "txn_id" aayega, ye DB me bank_txn_id column me save hoga
|
||||
@Id
|
||||
@JsonProperty("txn_id")
|
||||
@Column(name = "bank_txn_id", nullable = false, unique = true)
|
||||
private String bankTxnId;
|
||||
|
||||
// 👇 Apna internal transaction id, manually generate or system ke through
|
||||
@Column(name = "txn_id")
|
||||
private String txnId;
|
||||
|
||||
@Column(name = "req_id")
|
||||
private String reqId;
|
||||
|
||||
@Column(name = "ref_id")
|
||||
private String refId;
|
||||
|
||||
@Column(name = "txn_npci_id")
|
||||
private String txnNpciId;
|
||||
|
||||
@Column(name = "payment_ref_id")
|
||||
private String paymentRefId;
|
||||
|
||||
@Column(name = "remitter_name")
|
||||
private String remitterName;
|
||||
|
||||
@Column(name = "order_id")
|
||||
private String orderId;
|
||||
|
||||
@Column(name = "bill_id")
|
||||
private String billId;
|
||||
|
||||
@Column(name = "user_type")
|
||||
private String userType;
|
||||
|
||||
@Column(name = "user_id")
|
||||
private String userId;
|
||||
|
||||
@Column(name = "txn_amount")
|
||||
private Double txnAmount;
|
||||
|
||||
@Column(name = "total_txn_amount")
|
||||
private Double totalTxnAmount;
|
||||
|
||||
@Column(name = "biller_id")
|
||||
private String billerId;
|
||||
|
||||
@Column(name = "biller_category")
|
||||
private String billerCategory;
|
||||
|
||||
@Column(name = "biller_name")
|
||||
private String billerName;
|
||||
|
||||
@Column(name = "client_req_id")
|
||||
private String clientReqId;
|
||||
|
||||
@Column(name = "off_us_pay")
|
||||
private String offUsPay;
|
||||
|
||||
@Column(name = "split_pay")
|
||||
private String splitPay;
|
||||
|
||||
@Column(name = "quick_pay")
|
||||
private String quickPay;
|
||||
|
||||
@Column(name = "payment_mode")
|
||||
private String paymentMode;
|
||||
|
||||
@Column(name = "agent_payment_information", columnDefinition = "TEXT")
|
||||
private String agentPaymentInformation;
|
||||
|
||||
@Column(name = "cust_conv_fee")
|
||||
private Double custConvFee;
|
||||
|
||||
@Column(name = "currency")
|
||||
private String currency;
|
||||
|
||||
@Column(name = "status")
|
||||
private String status;
|
||||
|
||||
@Column(name = "requested_ip")
|
||||
private String requestedIp;
|
||||
|
||||
@Column(name = "customer_mob_no")
|
||||
private String customerMobNo;
|
||||
|
||||
@Column(name = "mac_address")
|
||||
private String macAddress;
|
||||
|
||||
@Column(name = "split_pay_amount")
|
||||
private Double splitPayAmount;
|
||||
|
||||
@Column(name = "cou_cust_conv_fee")
|
||||
private Double couCustConvFee;
|
||||
|
||||
@Column(name = "settlement_verification")
|
||||
private Boolean settlementVerification;
|
||||
|
||||
@Column(name = "fund_txn_type")
|
||||
private String fundTxnType;
|
||||
|
||||
@Column(name = "reason", columnDefinition = "TEXT")
|
||||
private String reason;
|
||||
|
||||
@Column(name = "amount_tags", columnDefinition = "TEXT")
|
||||
private String amountTags;
|
||||
|
||||
@Column(name = "payment_information", columnDefinition = "TEXT")
|
||||
private String paymentInformation;
|
||||
|
||||
// ✅ Relation with DeviceBlockTagEntity
|
||||
@OneToMany(mappedBy = "transactionMaster", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
private List<DeviceBlockTag> deviceBlockTags;
|
||||
|
||||
// ✅ Relation with CustomerParamEntity
|
||||
@OneToMany(mappedBy = "transactionMaster", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
private List<CustomerParamTransaction> customerParams;
|
||||
|
||||
@Column(name = "plan_id")
|
||||
private String planId;
|
||||
|
||||
@Column(name = "plan_type")
|
||||
private String planType;
|
||||
|
||||
@Column(name = "creation_date")
|
||||
private String creationDate;
|
||||
|
||||
@Column(name = "modified_date")
|
||||
private String modifiedDate;
|
||||
|
||||
@Column(name = "created_epoch_date")
|
||||
private Long createdEpochDate;
|
||||
|
||||
@Column(name = "modified_epoch_date")
|
||||
private Long modifiedEpochDate;
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package com.billpaymentservice.bbps.entites;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@Table(name = "transaction_status")
|
||||
public class TransactionStatus {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false, unique = true)
|
||||
private String txnId;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String refId;
|
||||
|
||||
private String txnNpciId;
|
||||
private String orderId;
|
||||
private String billId;
|
||||
private String userType;
|
||||
private String userId;
|
||||
private Double txnAmount;
|
||||
private Double totalTxnAmount;
|
||||
private String billerId;
|
||||
private String billerCategory;
|
||||
private String billerName;
|
||||
private String clientReqId;
|
||||
private String offUsPay;
|
||||
private String splitPay;
|
||||
private String quickPay;
|
||||
private String paymentMode;
|
||||
private Double custConvFee;
|
||||
private String currency;
|
||||
private String status;
|
||||
private String requestedIp;
|
||||
private String customerMobNo;
|
||||
private String macAddress;
|
||||
private Double splitPayAmount;
|
||||
private Double couCustConvFee;
|
||||
private Boolean settlementVerification;
|
||||
private String fundTxnType;
|
||||
private String reason;
|
||||
private String planId;
|
||||
private String planType;
|
||||
private LocalDateTime creationDate;
|
||||
private LocalDateTime modifiedDate;
|
||||
private Long createdEpochDate;
|
||||
private Long modifiedEpochDate;
|
||||
|
||||
@OneToOne(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "fund_transfer_id")
|
||||
private AgentFundTransferEntity agentFundTransfer;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "transaction_id")
|
||||
private List<CustomerParamDAO> customerParamsDAO;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.billpaymentservice.bbps.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import com.billpaymentservice.bbps.entites.AgentFundTransfer;
|
||||
|
||||
public interface AgentFundTransferRepository extends JpaRepository<AgentFundTransfer, String> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.billpaymentservice.bbps.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import com.billpaymentservice.bbps.entites.PaymentInitiate;
|
||||
|
||||
public interface PaymentIntiateRepository extends JpaRepository<PaymentInitiate, String> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.billpaymentservice.bbps.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import com.billpaymentservice.bbps.entites.TransactionMaster;
|
||||
|
||||
public interface TransactionMasterRepository extends JpaRepository<TransactionMaster, String> {
|
||||
|
||||
}
|
||||
@@ -121,16 +121,20 @@ public class AgentServiceImpl implements AgentService {
|
||||
billInitiate.setReqId(fetchBillRequest.getReqId());
|
||||
billInitiate.setTxnId(txnId);
|
||||
billIntiateRepository.save(billInitiate);
|
||||
|
||||
|
||||
BillFetchByBillIdRequest billFetchByBillIdRequest = new BillFetchByBillIdRequest();
|
||||
billFetchByBillIdRequest.setBillId(fetchBillResponse.getBillId());
|
||||
billFetchByBillIdRequest.setMid(fetchBillRequest.getMid());
|
||||
billFetchByBillIdRequest.setReqId(requestId);
|
||||
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt(); // restore interrupted flag
|
||||
log.warn("Thread interrupted during delay: {}", e.getMessage());
|
||||
}
|
||||
|
||||
return fetchBillById(billFetchByBillIdRequest, inboundLog);
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("❌ JSON Parsing Error: {}", e.getMessage());
|
||||
@@ -251,6 +255,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResponseModel initiateBillValidate(FetchBillValidatestRequest fetchBillValidateRequest) {
|
||||
|
||||
|
||||
@@ -249,6 +249,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
CustomParamResp responseWrapper = objectMapper.convertValue(dataMap, CustomParamResp.class);
|
||||
List<CustomParamDTO> customParams = responseWrapper.getCustomParamResp();
|
||||
|
||||
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
List<CustomParamDTO> customParam = responseWrapper.getCustomParamResp();
|
||||
|
||||
@@ -22,17 +22,25 @@ import com.billpaymentservice.bbps.dto.response.BillDataResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.BillPaymentResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.FetchBillResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.TransactionStatusResponse;
|
||||
import com.billpaymentservice.bbps.entites.AgentFundTransfer;
|
||||
import com.billpaymentservice.bbps.entites.BharatConnectMaster;
|
||||
import com.billpaymentservice.bbps.entites.BillInitiate;
|
||||
import com.billpaymentservice.bbps.entites.BillPayment;
|
||||
import com.billpaymentservice.bbps.entites.InboundTraceLog;
|
||||
import com.billpaymentservice.bbps.entites.OutboundTraceLog;
|
||||
import com.billpaymentservice.bbps.entites.PaymentInitiate;
|
||||
import com.billpaymentservice.bbps.entites.TransactionMaster;
|
||||
import com.billpaymentservice.bbps.exception.CustomException;
|
||||
import com.billpaymentservice.bbps.repository.AgentFundTransferRepository;
|
||||
import com.billpaymentservice.bbps.repository.BharatConnectMasterRepository;
|
||||
import com.billpaymentservice.bbps.repository.InboundTraceLogRepository;
|
||||
import com.billpaymentservice.bbps.repository.OutboundTraceLogRepository;
|
||||
import com.billpaymentservice.bbps.repository.PaymentIntiateRepository;
|
||||
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.EntityRelationshipUtil;
|
||||
import com.billpaymentservice.bbps.util.Helper;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
@@ -50,20 +58,27 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
private final PaymentRepository paymentRepository;
|
||||
private final InboundTraceLogRepository inboundTraceLogRepository;
|
||||
private final OutboundTraceLogRepository outboundTraceLogRepository;
|
||||
|
||||
private final PaymentIntiateRepository paymentIntiateRepository;
|
||||
private final TransactionMasterRepository transactionMasterRepository;
|
||||
private final AgentFundTransferRepository agentFundTransferRepository;
|
||||
public PaymentServiceImpl(BharatConnectMasterRepository beneficiaryDetailsRepository, HttpService httpService,
|
||||
Helper helper, PaymentRepository paymentRepository, InboundTraceLogRepository inboundTraceLogRepository,
|
||||
OutboundTraceLogRepository outboundTraceLogRepository) {
|
||||
OutboundTraceLogRepository outboundTraceLogRepository,
|
||||
PaymentIntiateRepository paymentIntiateRepository,
|
||||
TransactionMasterRepository transactionMasterRepository,
|
||||
AgentFundTransferRepository agentFundTransferRepository) {
|
||||
this.beneficiaryDetailsRepository = beneficiaryDetailsRepository;
|
||||
this.httpService = httpService;
|
||||
this.helper = helper;
|
||||
this.paymentRepository = paymentRepository;
|
||||
this.inboundTraceLogRepository = inboundTraceLogRepository;
|
||||
this.outboundTraceLogRepository = outboundTraceLogRepository;
|
||||
this.paymentIntiateRepository = paymentIntiateRepository;
|
||||
this.transactionMasterRepository = transactionMasterRepository;
|
||||
this.agentFundTransferRepository = agentFundTransferRepository;
|
||||
}
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(MasterDataServiceImpl.class);
|
||||
|
||||
@Override
|
||||
public ResponseModel initiatePayment(BillPaymentRequest billPaymentRequest) {
|
||||
String apiName = "InitiatePayment";
|
||||
@@ -114,27 +129,35 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
paymentRepository.save(entity);
|
||||
|
||||
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);
|
||||
// ✅ Trigger transaction status check
|
||||
TransactionStatusRequest transactionStatusRequest = new TransactionStatusRequest();
|
||||
transactionStatusRequest.setTxnId(entity.getTxnId());
|
||||
transactionStatusRequest.setTxnId(billPaymentResponse.getTxnId());
|
||||
transactionStatusRequest.setReqId(requestId);
|
||||
|
||||
|
||||
|
||||
try {
|
||||
Thread.sleep(2000); // Initial wait before first status check
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
LOGGER.error("Thread interrupted: {}", e.getMessage());
|
||||
}
|
||||
|
||||
//calling the method to check transaction status
|
||||
return checkTrasactionStatus(transactionStatusRequest, inboundLog);
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("❌ JSON Parsing Error: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
} catch (CustomException ce) {
|
||||
throw ce; // will be handled by global exception handler
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("❌ Exception in initiatePayment(): {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "EXCEPTION");
|
||||
throw new CustomException("Payment initiation failed: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest,InboundTraceLog inboundLog) {
|
||||
String apiName = "CheckTransactionStatus";
|
||||
@@ -152,11 +175,6 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
|
||||
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);
|
||||
@@ -178,20 +196,26 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
|
||||
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
|
||||
|
||||
System.out.println("Response Wrapper:"+responseWrapper);
|
||||
|
||||
|
||||
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);
|
||||
|
||||
AgentFundTransfer agentFundTransfer = mapper.map(responseWrapper.getAgentFundTransfer(), AgentFundTransfer.class);
|
||||
agentFundTransfer.setTxnId(txnId);
|
||||
agentFundTransfer.setReqId(transactionStatusRequest.getReqId());
|
||||
agentFundTransfer.setTransactionMasterId(transactionMaster.getBankTxnId());
|
||||
agentFundTransferRepository.save(agentFundTransfer);
|
||||
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(),
|
||||
@@ -206,14 +230,9 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest) {
|
||||
helper.validateMerchant(transactionStatusRequest.getMid());
|
||||
@@ -230,7 +249,7 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
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);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, "GET", null);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||
@@ -277,7 +296,7 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/* PollBack logic for the fetchTxnByTxnId API
|
||||
* @Override public ResponseModel fetchTxnByTxnId(BillFetchByBillIdRequest
|
||||
* billFetchByBillIdRequest) {
|
||||
*
|
||||
@@ -327,4 +346,75 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
* }
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* 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"); } }
|
||||
* }
|
||||
*
|
||||
*
|
||||
*/
|
||||
@@ -62,5 +62,29 @@ public class EntityRelationshipUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void linkTransactionMasterRelationships(TransactionMaster entity) {
|
||||
|
||||
if (entity == null) return;
|
||||
|
||||
// ✅ DeviceBlockTag relationship link karna
|
||||
if (entity.getDeviceBlockTags() != null) {
|
||||
entity.getDeviceBlockTags().forEach(tag -> {
|
||||
if (tag != null) {
|
||||
tag.setTransactionMaster(entity);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ✅ CustomerParamTransaction relationship link karna
|
||||
if (entity.getCustomerParams() != null) {
|
||||
entity.getCustomerParams().forEach(param -> {
|
||||
if (param != null) {
|
||||
param.setTransactionMaster(entity);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user