From ae298a35f63b993bc3c936bbcfe5e5f1df9b899c Mon Sep 17 00:00:00 2001 From: Lincpay Tech Date: Thu, 18 Dec 2025 23:24:38 +0530 Subject: [PATCH 1/3] delete some colums from payment start record --- .../bbps/entites/PaymentStartRecord.java | 20 +------------------ .../serviceImpl/PaymentStartServiceImpl.java | 10 +++------- .../bbps/util/BBPSConstant.java | 3 +++ .../bbps/util/BillerMapperHelper.java | 7 ------- 4 files changed, 7 insertions(+), 33 deletions(-) diff --git a/src/main/java/com/billpaymentservice/bbps/entites/PaymentStartRecord.java b/src/main/java/com/billpaymentservice/bbps/entites/PaymentStartRecord.java index 0e11856..75f5d25 100644 --- a/src/main/java/com/billpaymentservice/bbps/entites/PaymentStartRecord.java +++ b/src/main/java/com/billpaymentservice/bbps/entites/PaymentStartRecord.java @@ -50,32 +50,14 @@ public class PaymentStartRecord extends Auditable { @Column(name = "txn_id") private String txnId; - @Column(name = "qr_string", columnDefinition = "TEXT") - private String qrString; - - // `createdOn` is provided by the base `Auditable` class as a LocalDateTime field, - // so we must not redeclare it here (it caused an incompatible return-type error). - // The Auditable base class already defines `createdOn` of type LocalDateTime. - - // New callback-related fields @Column(name = "callback_status") private String callbackStatus; - @Column(name = "bank_response", columnDefinition = "TEXT") - private String bankResponse; - @Column(name = "signature") private String signature; - // Store original request body and full response body - @Column(name = "request_body", columnDefinition = "TEXT") - private String requestBody; - - @Column(name = "response_body", columnDefinition = "TEXT") - private String responseBody; - @Column(name = "response_type") - private String responseType; // e.g., "QR", "HTML", "JSON" + private String responseType; @Column(name = "txn_status") private String txnStatus; diff --git a/src/main/java/com/billpaymentservice/bbps/serviceImpl/PaymentStartServiceImpl.java b/src/main/java/com/billpaymentservice/bbps/serviceImpl/PaymentStartServiceImpl.java index 58a2c69..b62fa3e 100644 --- a/src/main/java/com/billpaymentservice/bbps/serviceImpl/PaymentStartServiceImpl.java +++ b/src/main/java/com/billpaymentservice/bbps/serviceImpl/PaymentStartServiceImpl.java @@ -164,8 +164,7 @@ public class PaymentStartServiceImpl implements PaymentStartService { // success: persist and return helper.updateInboundLogSuccess(inboundLog, respBody, String.valueOf(outcomeCode)); - String responseType = (apiResponse.getResponseData() != null && apiResponse.getResponseData().getQrString() != null && !apiResponse.getResponseData().getQrString().isEmpty()) ? BBPSConstant.RESPONSE_TYPE_QR : BBPSConstant.RESPONSE_TYPE_JSON; - + String responseType = BBPSConstant.RESPONSE_TYPE_INTENT; bbpsMapperHelper.savePaymentStartRecord(request, apiResponse, txnId, orderNo, requestJson, respBody, responseType); LOGGER.info("[startIntentPayment] saved record txnId={} orderNo={} responseType={}", txnId, orderNo, responseType); @@ -294,7 +293,7 @@ public class PaymentStartServiceImpl implements PaymentStartService { LOGGER.info("[startWebPayment] received HTML response txnId={} length={}", txnId, respBody.length()); // Save record with HTML (persist original request and HTML response) - String responseTypeWeb = BBPSConstant.RESPONSE_TYPE_HTML; + String responseTypeWeb = BBPSConstant.RESPONSE_TYPE_WEB; String rawResponseWeb = respBody == null ? "" : respBody; // Try to extract useful fields from returned HTML (txnId, amount, mid) @@ -313,7 +312,7 @@ public class PaymentStartServiceImpl implements PaymentStartService { rd.setAmount(parsedAmount != null && !parsedAmount.isEmpty() ? parsedAmount : "0.00"); rd.setMid(parsedMid); rd.setOrderNo(orderNo); - rd.setQrString("HTML_RESPONSE"); + rd.setQrString(BBPSConstant.RESPONSE_TYPE_WEB); rd.setCreatedOn(LocalDateTime.now().toString()); apiResp.setResponseData(rd); @@ -401,10 +400,7 @@ public class PaymentStartServiceImpl implements PaymentStartService { return new ResponseModel(BBPSConstant.MSG_NO_MATCHING_RECORD, BBPSConstant.MERCHANT_ACK_NO_MATCH, BBPSConstant.HTTP_OK_INT, null); } - // Update record with bank response and signature - record.setBankResponse(decrypted); record.setSignature(signature); - // update txn status and callback timestamp record.setTxnStatus(txnStatus); record.setCallbackReceivedOn(java.time.LocalDateTime.now().toString()); diff --git a/src/main/java/com/billpaymentservice/bbps/util/BBPSConstant.java b/src/main/java/com/billpaymentservice/bbps/util/BBPSConstant.java index db0486c..9a33427 100644 --- a/src/main/java/com/billpaymentservice/bbps/util/BBPSConstant.java +++ b/src/main/java/com/billpaymentservice/bbps/util/BBPSConstant.java @@ -222,6 +222,9 @@ public class BBPSConstant extends BBPS_RESPONSE_COD_CONSTANT { public static final String INTERNALSERVER_ERROR_STR = "600"; public static final String USER_UNAUTHORIZED_STR = "401"; public static final String OK_STR = "200"; + public static final String RESPONSE_TYPE_INTENT = "INTENT"; + public static final String RESPONSE_TYPE_WEB = "WEB"; + // Newly added constant for invalid JSON status code diff --git a/src/main/java/com/billpaymentservice/bbps/util/BillerMapperHelper.java b/src/main/java/com/billpaymentservice/bbps/util/BillerMapperHelper.java index 7d829cd..8d1c0ce 100644 --- a/src/main/java/com/billpaymentservice/bbps/util/BillerMapperHelper.java +++ b/src/main/java/com/billpaymentservice/bbps/util/BillerMapperHelper.java @@ -721,7 +721,6 @@ public class BillerMapperHelper { parent.setUserId(responseWrapper.getUserId()); // Map incoming DTO date strings into Auditable LocalDateTime fields Date parentCreatedOn = parseToDate(responseWrapper.getCreationDate()); - Date parentUpdatedOn = parseToDate(responseWrapper.getModifiedDate()); parent.setCreatedEpochDate(responseWrapper.getCreatedEpochDate()); parent.setModifiedEpochDate(responseWrapper.getModifiedEpochDate()); @@ -1130,9 +1129,6 @@ public class BillerMapperHelper { record.setTxnId(Optional.ofNullable( apiResponse.getResponseData().getTxnId()).orElse("DUMMY_TXN")); - record.setQrString(Optional.ofNullable( - apiResponse.getResponseData().getQrString()).orElse("NO_QR")); - Date createdOn = parseToDate(apiResponse.getResponseData().getCreatedOn()); record.setTxnStatus("PENDING"); @@ -1141,9 +1137,6 @@ public class BillerMapperHelper { record.setTxnStatus("PENDING"); } - // Raw request/response - record.setRequestBody(requestJson); - record.setResponseBody(rawResponse); record.setResponseType(responseType); return paymentStartRecordRepository.save(record); From a4842788c13e808fd4ec05f78aaaabdacb9ae25f Mon Sep 17 00:00:00 2001 From: Lincpay Tech Date: Mon, 22 Dec 2025 10:32:29 +0530 Subject: [PATCH 2/3] removed and added lombook for the login,verify,payment,transaction --- .../bbps/dto/auth/LoginRequest.java | 17 +++------- .../bbps/dto/auth/VerifyOtpRequest.java | 31 +++++-------------- .../bbps/entites/PaymentStartRecord.java | 2 +- .../bbps/entites/TransactionMaster.java | 2 +- .../resources/application-local.properties | 4 +-- 5 files changed, 16 insertions(+), 40 deletions(-) diff --git a/src/main/java/com/billpaymentservice/bbps/dto/auth/LoginRequest.java b/src/main/java/com/billpaymentservice/bbps/dto/auth/LoginRequest.java index 1f7d944..760d987 100644 --- a/src/main/java/com/billpaymentservice/bbps/dto/auth/LoginRequest.java +++ b/src/main/java/com/billpaymentservice/bbps/dto/auth/LoginRequest.java @@ -3,7 +3,11 @@ package com.billpaymentservice.bbps.dto.auth; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Pattern; import jakarta.validation.constraints.Size; +import lombok.Getter; +import lombok.Setter; +@Getter +@Setter public class LoginRequest { @NotNull(message = "Mobile number cannot be null.") @@ -11,18 +15,5 @@ public class LoginRequest { @Pattern(regexp = "^[0-9]{10}$", message = "Mobile number must contain only digits.") private String mobile; - public LoginRequest() { - } - public LoginRequest(String mobile) { - this.mobile = mobile; - } - - public String getMobile() { - return mobile; - } - - public void setMobile(String mobile) { - this.mobile = mobile; - } } diff --git a/src/main/java/com/billpaymentservice/bbps/dto/auth/VerifyOtpRequest.java b/src/main/java/com/billpaymentservice/bbps/dto/auth/VerifyOtpRequest.java index aa6ce8d..58b523d 100644 --- a/src/main/java/com/billpaymentservice/bbps/dto/auth/VerifyOtpRequest.java +++ b/src/main/java/com/billpaymentservice/bbps/dto/auth/VerifyOtpRequest.java @@ -3,7 +3,15 @@ package com.billpaymentservice.bbps.dto.auth; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Pattern; import jakarta.validation.constraints.Size; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor public class VerifyOtpRequest { @NotNull(message = "Mobile number cannot be null.") @@ -16,27 +24,4 @@ public class VerifyOtpRequest { @Pattern(regexp = "^[0-9]{6}$", message = "OTP must contain only 6 digits.") private String otp; - public VerifyOtpRequest() { - } - - public VerifyOtpRequest(String mobile, String otp) { - this.mobile = mobile; - this.otp = otp; - } - - public String getMobile() { - return mobile; - } - - public void setMobile(String mobile) { - this.mobile = mobile; - } - - public String getOtp() { - return otp; - } - - public void setOtp(String otp) { - this.otp = otp; - } } diff --git a/src/main/java/com/billpaymentservice/bbps/entites/PaymentStartRecord.java b/src/main/java/com/billpaymentservice/bbps/entites/PaymentStartRecord.java index 4cfb463..9bcf60a 100644 --- a/src/main/java/com/billpaymentservice/bbps/entites/PaymentStartRecord.java +++ b/src/main/java/com/billpaymentservice/bbps/entites/PaymentStartRecord.java @@ -47,7 +47,7 @@ public class PaymentStartRecord extends Auditable { @Column(name = "amount", nullable = false) private String amount; - @Column(name = "txn_id") + @Column(name = "txn_id",unique = true) private String txnId; @Column(name = "qr_string", columnDefinition = "TEXT") diff --git a/src/main/java/com/billpaymentservice/bbps/entites/TransactionMaster.java b/src/main/java/com/billpaymentservice/bbps/entites/TransactionMaster.java index 77a3a22..6d05d79 100644 --- a/src/main/java/com/billpaymentservice/bbps/entites/TransactionMaster.java +++ b/src/main/java/com/billpaymentservice/bbps/entites/TransactionMaster.java @@ -39,7 +39,7 @@ public class TransactionMaster extends Auditable { @Column(name = "bank_txn_id",unique = true) private String bankTxnId; - @Column(name = "txn_id") + @Column(name = "txn_id",unique = true) private String txnId; @Column(name = "initiator_txn_id") diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties index 79e2fdd..5d343ea 100644 --- a/src/main/resources/application-local.properties +++ b/src/main/resources/application-local.properties @@ -23,9 +23,9 @@ swagger.server.description=Local Development Server spring.datasource.url=jdbc:postgresql://localhost:5432/bbps_enhanced spring.datasource.username=postgres -spring.datasource.password=UAT@DB_2025 +#spring.datasource.password=UAT@DB_2025 -#spring.datasource.password=himanshu@123 +spring.datasource.password=himanshu@123 spring.datasource.driver-class-name=org.postgresql.Driver spring.datasource.type=com.zaxxer.hikari.HikariDataSource From 5d0f043848a034c4736b0100f9e9656581bce2f5 Mon Sep 17 00:00:00 2001 From: Lincpay Tech Date: Mon, 22 Dec 2025 17:12:54 +0530 Subject: [PATCH 3/3] improved bill fetching data is getting saved before making call --- .../bbps/dto/TransactionHistoryMasterDTO.java | 12 +-- ...ransactionHistoryParticularDetailsDTO.java | 2 +- .../bbps/dto/auth/LoginRequest.java | 21 ++--- .../bbps/dto/auth/OtpSendResponse.java | 32 +++---- .../bbps/dto/auth/RegisterRequest.java | 4 + .../bbps/dto/auth/VerifyOtpRequest.java | 32 ++----- .../bbps/entites/BillMaster.java | 11 ++- .../bbps/entites/BillValidation.java | 17 ++-- .../bbps/entites/TransactionMaster.java | 12 +-- .../bbps/repository/BillMasterRepository.java | 15 +++- .../repository/BillValidationRepository.java | 4 +- .../bbps/serviceImpl/AgentServiceImpl.java | 83 ++++++++++--------- .../bbps/serviceImpl/PaymentServiceImpl.java | 1 - .../bbps/util/BillerMapperHelper.java | 10 +-- .../billpaymentservice/bbps/util/Helper.java | 7 ++ .../resources/application-local.properties | 4 +- 16 files changed, 138 insertions(+), 129 deletions(-) diff --git a/src/main/java/com/billpaymentservice/bbps/dto/TransactionHistoryMasterDTO.java b/src/main/java/com/billpaymentservice/bbps/dto/TransactionHistoryMasterDTO.java index 8ca20f3..101862e 100644 --- a/src/main/java/com/billpaymentservice/bbps/dto/TransactionHistoryMasterDTO.java +++ b/src/main/java/com/billpaymentservice/bbps/dto/TransactionHistoryMasterDTO.java @@ -22,8 +22,8 @@ public class TransactionHistoryMasterDTO { private String billId; private String userType; private String userId; - private Double txnAmount; - private Double totalTxnAmount; + private String txnAmount; + private String totalTxnAmount; private String billerId; private String billerCategory; private String billerName; @@ -33,15 +33,15 @@ public class TransactionHistoryMasterDTO { private String quickPay; private String paymentMode; private String agentPaymentInformation; - private Double custConvFee; + private String 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 splitPayAmount; + private String couCustConvFee; + private String settlementVerification; private String fundTxnType; private String reason; private String amountTags; diff --git a/src/main/java/com/billpaymentservice/bbps/dto/TransactionHistoryParticularDetailsDTO.java b/src/main/java/com/billpaymentservice/bbps/dto/TransactionHistoryParticularDetailsDTO.java index 8c2e266..a8feffc 100644 --- a/src/main/java/com/billpaymentservice/bbps/dto/TransactionHistoryParticularDetailsDTO.java +++ b/src/main/java/com/billpaymentservice/bbps/dto/TransactionHistoryParticularDetailsDTO.java @@ -11,7 +11,7 @@ public class TransactionHistoryParticularDetailsDTO { private String billerName; - private Double totalTxnAmount; + private String totalTxnAmount; private String bankTxnId; diff --git a/src/main/java/com/billpaymentservice/bbps/dto/auth/LoginRequest.java b/src/main/java/com/billpaymentservice/bbps/dto/auth/LoginRequest.java index 1f7d944..a99576b 100644 --- a/src/main/java/com/billpaymentservice/bbps/dto/auth/LoginRequest.java +++ b/src/main/java/com/billpaymentservice/bbps/dto/auth/LoginRequest.java @@ -3,7 +3,15 @@ package com.billpaymentservice.bbps.dto.auth; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Pattern; import jakarta.validation.constraints.Size; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor public class LoginRequest { @NotNull(message = "Mobile number cannot be null.") @@ -11,18 +19,5 @@ public class LoginRequest { @Pattern(regexp = "^[0-9]{10}$", message = "Mobile number must contain only digits.") private String mobile; - public LoginRequest() { - } - public LoginRequest(String mobile) { - this.mobile = mobile; - } - - public String getMobile() { - return mobile; - } - - public void setMobile(String mobile) { - this.mobile = mobile; - } } diff --git a/src/main/java/com/billpaymentservice/bbps/dto/auth/OtpSendResponse.java b/src/main/java/com/billpaymentservice/bbps/dto/auth/OtpSendResponse.java index 67dc6ff..aff51f1 100644 --- a/src/main/java/com/billpaymentservice/bbps/dto/auth/OtpSendResponse.java +++ b/src/main/java/com/billpaymentservice/bbps/dto/auth/OtpSendResponse.java @@ -1,29 +1,17 @@ package com.billpaymentservice.bbps.dto.auth; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor public class OtpSendResponse { private boolean success; private String message; - public OtpSendResponse() {} - - public OtpSendResponse(boolean success, String message) { - this.success = success; - this.message = message; - } - - public boolean isSuccess() { - return success; - } - - public void setSuccess(boolean success) { - this.success = success; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } + } diff --git a/src/main/java/com/billpaymentservice/bbps/dto/auth/RegisterRequest.java b/src/main/java/com/billpaymentservice/bbps/dto/auth/RegisterRequest.java index 1905d7a..bb1629d 100644 --- a/src/main/java/com/billpaymentservice/bbps/dto/auth/RegisterRequest.java +++ b/src/main/java/com/billpaymentservice/bbps/dto/auth/RegisterRequest.java @@ -6,11 +6,15 @@ import jakarta.validation.constraints.Email; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Pattern; import jakarta.validation.constraints.Size; +import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; @Getter @Setter +@NoArgsConstructor +@AllArgsConstructor public class RegisterRequest extends BaseClass { @NotNull(message = "Mobile number cannot be null.") diff --git a/src/main/java/com/billpaymentservice/bbps/dto/auth/VerifyOtpRequest.java b/src/main/java/com/billpaymentservice/bbps/dto/auth/VerifyOtpRequest.java index aa6ce8d..e65d335 100644 --- a/src/main/java/com/billpaymentservice/bbps/dto/auth/VerifyOtpRequest.java +++ b/src/main/java/com/billpaymentservice/bbps/dto/auth/VerifyOtpRequest.java @@ -3,7 +3,15 @@ package com.billpaymentservice.bbps.dto.auth; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Pattern; import jakarta.validation.constraints.Size; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor public class VerifyOtpRequest { @NotNull(message = "Mobile number cannot be null.") @@ -16,27 +24,5 @@ public class VerifyOtpRequest { @Pattern(regexp = "^[0-9]{6}$", message = "OTP must contain only 6 digits.") private String otp; - public VerifyOtpRequest() { - } - - public VerifyOtpRequest(String mobile, String otp) { - this.mobile = mobile; - this.otp = otp; - } - - public String getMobile() { - return mobile; - } - - public void setMobile(String mobile) { - this.mobile = mobile; - } - - public String getOtp() { - return otp; - } - - public void setOtp(String otp) { - this.otp = otp; - } + } diff --git a/src/main/java/com/billpaymentservice/bbps/entites/BillMaster.java b/src/main/java/com/billpaymentservice/bbps/entites/BillMaster.java index 91609e2..2f98af2 100644 --- a/src/main/java/com/billpaymentservice/bbps/entites/BillMaster.java +++ b/src/main/java/com/billpaymentservice/bbps/entites/BillMaster.java @@ -5,6 +5,8 @@ import java.util.List; import jakarta.persistence.CascadeType; import jakarta.persistence.Column; import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; import jakarta.persistence.OneToMany; @@ -26,16 +28,23 @@ import lombok.Setter; public class BillMaster extends Auditable { @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + @Column(name = "bill_id", unique = true) private String billId; // primary key - private String reqId; // client se aaya hua private String txnId; // system-generated private String refId; private String billerId; private String status; + private String mid; private String actionType; private String clientUserId; private String userId; + @Column(name = "initiator_txn_id") + private String initiatorTxnId; + @Column(name = "checker_txn_id") + private String checkerTxnId; @OneToOne(cascade = CascadeType.ALL) @JoinColumn(name = "biller_response_id") private BillerResponse billerResponse; diff --git a/src/main/java/com/billpaymentservice/bbps/entites/BillValidation.java b/src/main/java/com/billpaymentservice/bbps/entites/BillValidation.java index fc507c7..693e36b 100644 --- a/src/main/java/com/billpaymentservice/bbps/entites/BillValidation.java +++ b/src/main/java/com/billpaymentservice/bbps/entites/BillValidation.java @@ -8,15 +8,24 @@ import lombok.Data; import lombok.NoArgsConstructor; @Entity -@Table(name = "bbps_bill_validation") +@Table(name = "bbps_bill_validation_master") @Data @AllArgsConstructor @NoArgsConstructor public class BillValidation extends Auditable { - @Id - @Column(name = "bill_id", nullable = false, length = 100) + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "bill_id", unique = true) private String billId; + + private String mid; + + private String initiatorTxnId; + + private String checkerTxnId; @Column(name = "ref_id", length = 100) private String refId; @@ -55,6 +64,4 @@ public class BillValidation extends Auditable { @Column(name = "client_user_id") private String clientUserId; - // Removed local audit fields: creationDate, modifiedDate, createdEpochDate, modifiedEpochDate - // They are now handled by Auditable base class } \ No newline at end of file diff --git a/src/main/java/com/billpaymentservice/bbps/entites/TransactionMaster.java b/src/main/java/com/billpaymentservice/bbps/entites/TransactionMaster.java index 77a3a22..afa6fa7 100644 --- a/src/main/java/com/billpaymentservice/bbps/entites/TransactionMaster.java +++ b/src/main/java/com/billpaymentservice/bbps/entites/TransactionMaster.java @@ -82,10 +82,10 @@ public class TransactionMaster extends Auditable { private String userId; @Column(name = "txn_amount") - private Double txnAmount; + private String txnAmount; @Column(name = "total_txn_amount") - private Double totalTxnAmount; + private String totalTxnAmount; @Column(name = "biller_id") private String billerId; @@ -115,7 +115,7 @@ public class TransactionMaster extends Auditable { private String agentPaymentInformation; @Column(name = "cust_conv_fee") - private Double custConvFee; + private String custConvFee; @Column(name = "currency") private String currency; @@ -133,13 +133,13 @@ public class TransactionMaster extends Auditable { private String macAddress; @Column(name = "split_pay_amount") - private Double splitPayAmount; + private String splitPayAmount; @Column(name = "cou_cust_conv_fee") - private Double couCustConvFee; + private String couCustConvFee; @Column(name = "settlement_verification") - private Boolean settlementVerification; + private String settlementVerification; @Column(name = "fund_txn_type") private String fundTxnType; diff --git a/src/main/java/com/billpaymentservice/bbps/repository/BillMasterRepository.java b/src/main/java/com/billpaymentservice/bbps/repository/BillMasterRepository.java index 161a85a..50258f0 100644 --- a/src/main/java/com/billpaymentservice/bbps/repository/BillMasterRepository.java +++ b/src/main/java/com/billpaymentservice/bbps/repository/BillMasterRepository.java @@ -4,6 +4,17 @@ import org.springframework.data.jpa.repository.JpaRepository; import com.billpaymentservice.bbps.entites.BillMaster; -public interface BillMasterRepository extends JpaRepository { +import java.util.Optional; -} +/** + * Repository for BillMaster. Added convenience finder methods so service + * can look up records by client request id (reqId) or txnId. + */ +public interface BillMasterRepository extends JpaRepository { + + Optional findByReqId(String reqId); + + Optional findByTxnId(String txnId); + BillMaster findByInitiatorTxnId(String initiatorTxnId); + +} diff --git a/src/main/java/com/billpaymentservice/bbps/repository/BillValidationRepository.java b/src/main/java/com/billpaymentservice/bbps/repository/BillValidationRepository.java index 6926652..e0c9bb0 100644 --- a/src/main/java/com/billpaymentservice/bbps/repository/BillValidationRepository.java +++ b/src/main/java/com/billpaymentservice/bbps/repository/BillValidationRepository.java @@ -6,6 +6,8 @@ import org.springframework.stereotype.Repository; import com.billpaymentservice.bbps.entites.BillValidation; @Repository -public interface BillValidationRepository extends JpaRepository { +public interface BillValidationRepository extends JpaRepository { + + BillValidation findByInitiatorTxnId(String txnId); } diff --git a/src/main/java/com/billpaymentservice/bbps/serviceImpl/AgentServiceImpl.java b/src/main/java/com/billpaymentservice/bbps/serviceImpl/AgentServiceImpl.java index 35ecdeb..c970297 100644 --- a/src/main/java/com/billpaymentservice/bbps/serviceImpl/AgentServiceImpl.java +++ b/src/main/java/com/billpaymentservice/bbps/serviceImpl/AgentServiceImpl.java @@ -22,12 +22,14 @@ import com.billpaymentservice.bbps.dto.sentRequest.FetchBillForwardRequest; import com.billpaymentservice.bbps.dto.sentRequest.FetchBillValidatestForwardRequest; import com.billpaymentservice.bbps.entites.BillInitiate; import com.billpaymentservice.bbps.entites.BillMaster; +import com.billpaymentservice.bbps.entites.BillValidation; import com.billpaymentservice.bbps.entites.InboundTraceLog; import com.billpaymentservice.bbps.entites.OutboundTraceLog; import com.billpaymentservice.bbps.exception.CustomException; import com.billpaymentservice.bbps.repository.BharatConnectMasterRepository; import com.billpaymentservice.bbps.repository.BillInitateRepository; import com.billpaymentservice.bbps.repository.BillMasterRepository; +import com.billpaymentservice.bbps.repository.BillValidationRepository; import com.billpaymentservice.bbps.repository.InboundTraceLogRepository; import com.billpaymentservice.bbps.repository.OutboundTraceLogRepository; import com.billpaymentservice.bbps.service.AgentService; @@ -52,6 +54,7 @@ public class AgentServiceImpl implements AgentService { private final BillerMapperHelper mapperHelper; private final BillMasterRepository billMasterRepository; private final BillInitateRepository billIntiateRepository; + private final BillValidationRepository billValidationRepository; private static final Logger LOGGER = LoggerFactory.getLogger(AgentServiceImpl.class); // Reusable ObjectMapper instance @@ -62,7 +65,7 @@ public class AgentServiceImpl implements AgentService { BharatConnectMasterRepository beneficiaryDetailsRepository, InboundTraceLogRepository inboundTraceLogRepository, OutboundTraceLogRepository outboundTraceLogRepository, BillMasterRepository billMasterRepository, BillInitateRepository billIntiateRepository, - BillerMapperHelper mapperHelper) { + BillerMapperHelper mapperHelper,BillValidationRepository billValidationRepository) { this.restClient = restClient; this.httpService = httpService; this.helper = helper; @@ -70,6 +73,7 @@ public class AgentServiceImpl implements AgentService { this.billMasterRepository = billMasterRepository; this.billIntiateRepository = billIntiateRepository; this.mapperHelper = mapperHelper; + this.billValidationRepository=billValidationRepository; } @Override @@ -94,7 +98,13 @@ public class AgentServiceImpl implements AgentService { OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, fullUrl, BBPSConstant.HTTP_POST, forwardJson); LOGGER.debug("Outbound log created successfully for txnId: {} and reqId: {}", txnId, requestId); - + + BillMaster billMaster =new BillMaster(); + billMaster.setReqId(fetchBillRequest.getReqId()); + billMaster.setInitiatorTxnId(txnId); + billMaster.setMid(fetchBillRequest.getMid()); + billMaster.setClientUserId(fetchBillRequest.getClientUserId()); + billMasterRepository.save(billMaster); try { LOGGER.info("[{}] Calling external API | URL={}", apiName, fullUrl); Map responseMap = httpService.postRequest(fullUrl, forwardJson, @@ -114,26 +124,13 @@ public class AgentServiceImpl implements AgentService { Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), String.valueOf(dataMap.get("remarks"))); } - - BillMaster billMaster = new BillMaster(); - billMaster.setBillId((String) dataMap.get("billId")); - billMaster.setReqId(fetchBillRequest.getReqId()); - billMaster.setTxnId(txnId); - billMaster.setClientUserId(fetchBillRequest.getClientUserId()); - 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()); - BillInitiate billInitiate = new BillInitiate(); - billInitiate.setBillId((String) dataMap.get("billId")); - billInitiate.setReqId(fetchBillRequest.getReqId()); - billInitiate.setTxnId(txnId); - billInitiate.setClientUserId(fetchBillRequest.getClientUserId()); - billIntiateRepository.save(billInitiate); - LOGGER.info("BillInitiate entry saved for billId: {}", billInitiate.getBillId()); BillFetchByBillIdRequest billFetchByBillIdRequest = new BillFetchByBillIdRequest(); billFetchByBillIdRequest.setBillId(fetchBillResponse.getBillId()); @@ -146,6 +143,7 @@ public class AgentServiceImpl implements AgentService { Thread.currentThread().interrupt(); LOGGER.warn("Thread interrupted during delay: {}", e.getMessage()); } + LOGGER.info("Calling internal method Fetching bill by ID: {}", billFetchByBillIdRequest.getBillId()); LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResponse.getStatus()); return fetchBillById(billFetchByBillIdRequest, inboundLog); @@ -171,6 +169,8 @@ public class AgentServiceImpl implements AgentService { LOGGER.debug("Outbound log created successfully for FetchBillById: {}", fullUrl); try { + + LOGGER.info("Calling external API: {}", fullUrl); Map responseMap = httpService.getRequest(fullUrl, helper.buildHeaders(beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID))); @@ -192,15 +192,18 @@ public class AgentServiceImpl implements AgentService { } BillDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillDataResponse.class); - GeneralResp generalResp = responseWrapper.getGenericResponse(); - + GeneralResp generalResp = responseWrapper.getGenericResponse(); + + + BillMaster + existingbill=billMasterRepository.findByInitiatorTxnId( + inboundLog.getTxnId()); String status = generalResp.getStatus(); LOGGER.info("Current Bill Status: {}", status); helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus()); - mapperHelper.saveOrUpdateBillData(responseWrapper, billFetchByBillIdRequest, txnId, reqId, userId); + mapperHelper.saveOrUpdateBillData(responseWrapper, billFetchByBillIdRequest, txnId, reqId,billFetchByBillIdRequest.getClientUserId(), existingbill); LOGGER.info("Bill data saved successfully for billId: {}", billId); - return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(), Integer.parseInt(generalResp.getStatusCode()), responseWrapper); } catch (JsonProcessingException e) { @@ -255,7 +258,7 @@ public class AgentServiceImpl implements AgentService { // update inbound log success and persist bill data helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus()); - mapperHelper.saveOrUpdateBillData(responseWrapper, billFetchByBillIdRequest, txnId, reqId, userId); + //mapperHelper.saveOrUpdateBillData(responseWrapper, billFetchByBillIdRequest, txnId, reqId, userId); LOGGER.info("Bill data saved successfully for billId={} | Status={}", billId, generalResp.getStatus()); LOGGER.info("[{}] END | reqId={} | status={}", apiName, reqId, generalResp.getStatus()); return responseModel; @@ -294,8 +297,14 @@ public class AgentServiceImpl implements AgentService { forwardJson); LOGGER.debug("Outbound log created successfully for txnId: {} and reqId: {}", txnId, reqId); + BillValidation billValidation = new BillValidation(); + billValidation.setReqId(fetchBillValidateRequest.getReqId()); + billValidation.setInitiatorTxnId(txnId); + billValidation.setMid(fetchBillValidateRequest.getMid()); + billValidation.setClientUserId(fetchBillValidateRequest.getClientUserId()); + billValidationRepository.save(billValidation); + try { - LOGGER.info("[{}] Calling external API | URL={}", apiName, fullUrl); Map responseMap = httpService.postRequest(fullUrl, forwardJson, helper.buildHeaders(beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID))); @@ -314,24 +323,11 @@ public class AgentServiceImpl implements AgentService { Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), String.valueOf(dataMap.get("remarks"))); } - - BillMaster billMaster = new BillMaster(); - billMaster.setBillId((String) dataMap.get("billId")); - billMaster.setReqId(fetchBillValidateRequest.getReqId()); - 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()); - - BillInitiate billInitiate = new BillInitiate(); - billInitiate.setBillId((String) dataMap.get("billId")); - billInitiate.setReqId(fetchBillValidateRequest.getReqId()); - billInitiate.setTxnId(txnId); - billIntiateRepository.save(billInitiate); - LOGGER.info("BillInitiate entry saved for billId: {}", billInitiate.getBillId()); - + BillFetchByBillIdRequest billFetchByBillIdRequest = new BillFetchByBillIdRequest(); billFetchByBillIdRequest.setBillId(fetchBillResponse.getBillId()); billFetchByBillIdRequest.setMid(fetchBillValidateRequest.getMid()); @@ -362,7 +358,11 @@ public class AgentServiceImpl implements AgentService { String reqId = billRequest.getReqId(); String billId = billRequest.getBillId(); String fullUrl = agentDtaUrl + BBPSConstant.BILL_VALIDATE_ID_URL + billRequest.getBillId(); - + + BillValidation + billValidation=billValidationRepository.findByInitiatorTxnId( + inboundLog.getTxnId()); + billValidation.setCheckerTxnId(txnId); OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET, null); LOGGER.debug("Outbound log created successfully for FetchBillById: {}", fullUrl); @@ -392,13 +392,14 @@ public class AgentServiceImpl implements AgentService { 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); - mapperHelper.saveBillValidation(responseWrapper, billRequest, txnId); + mapperHelper.saveBillValidation(responseWrapper, billRequest, txnId,billValidation); return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(), Integer.parseInt(generalResp.getStatusCode()), responseWrapper); } catch (JsonProcessingException e) { @@ -456,7 +457,7 @@ public class AgentServiceImpl implements AgentService { GeneralResp generalResp = responseWrapper.getGenericResponse(); helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus()); - mapperHelper.saveBillValidation(responseWrapper, billRequest, txnId); + //mapperHelper.saveBillValidation(responseWrapper, billRequest, txnId); LOGGER.info("Bill validation saved successfully for billId: {}", billId); LOGGER.info("[{}] END | reqId={} | status={}", apiName, reqId, generalResp.getStatus()); return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(), diff --git a/src/main/java/com/billpaymentservice/bbps/serviceImpl/PaymentServiceImpl.java b/src/main/java/com/billpaymentservice/bbps/serviceImpl/PaymentServiceImpl.java index 21efaf1..aec396e 100644 --- a/src/main/java/com/billpaymentservice/bbps/serviceImpl/PaymentServiceImpl.java +++ b/src/main/java/com/billpaymentservice/bbps/serviceImpl/PaymentServiceImpl.java @@ -112,7 +112,6 @@ public class PaymentServiceImpl implements PaymentService { LOGGER.debug("Outbound log created for api={} | reqId={} | txnId={}", apiName, requestId, txnId); TransactionMaster preTransaction=null; - preTransaction = new TransactionMaster(); preTransaction.setTxnId(txnId); preTransaction.setInitiatorTxnId(txnId); diff --git a/src/main/java/com/billpaymentservice/bbps/util/BillerMapperHelper.java b/src/main/java/com/billpaymentservice/bbps/util/BillerMapperHelper.java index 2aab006..d254b08 100644 --- a/src/main/java/com/billpaymentservice/bbps/util/BillerMapperHelper.java +++ b/src/main/java/com/billpaymentservice/bbps/util/BillerMapperHelper.java @@ -53,6 +53,7 @@ import com.billpaymentservice.bbps.dto.response.BillDataResponse; import com.billpaymentservice.bbps.dto.response.ClientReqIdResponse; import com.billpaymentservice.bbps.dto.response.ComplaintHistoryStatusResponse; import com.billpaymentservice.bbps.dto.response.ComplaintResponse; +import com.billpaymentservice.bbps.dto.response.FetchBillValidateResponse; import com.billpaymentservice.bbps.dto.response.PaymentStartApiResponse; import com.billpaymentservice.bbps.dto.response.PlanResponse; import com.billpaymentservice.bbps.dto.response.TicketCheckStatusResponse; @@ -817,9 +818,8 @@ public class BillerMapperHelper { } public void saveOrUpdateBillData(BillDataResponse responseWrapper, - BillFetchByBillIdRequest billFetchByBillIdRequest, String txnId, String reqId, String userId) { + BillFetchByBillIdRequest billFetchByBillIdRequest, String txnId, String reqId, String userId,BillMaster billMaster) { - BillMaster billMaster = new BillMaster(); billMaster.setBillId(responseWrapper.getBillId()); billMaster.setRefId(responseWrapper.getRefId()); @@ -1166,11 +1166,11 @@ public class BillerMapperHelper { return f; } - public void saveBillValidation(com.billpaymentservice.bbps.dto.response.FetchBillValidateResponse responseWrapper, - com.billpaymentservice.bbps.dto.request.BillFetchByBillIdRequest billRequest, String txnId) { + public void saveBillValidation(FetchBillValidateResponse responseWrapper, + BillFetchByBillIdRequest billRequest, String txnId,BillValidation entity) { if (responseWrapper == null || billRequest == null) return; - BillValidation entity = new BillValidation(); + entity.setBillId(responseWrapper.getBillId()); entity.setRefId(responseWrapper.getRefId()); entity.setBillerId(responseWrapper.getBillerId()); diff --git a/src/main/java/com/billpaymentservice/bbps/util/Helper.java b/src/main/java/com/billpaymentservice/bbps/util/Helper.java index 827aff5..a8d7876 100644 --- a/src/main/java/com/billpaymentservice/bbps/util/Helper.java +++ b/src/main/java/com/billpaymentservice/bbps/util/Helper.java @@ -14,8 +14,10 @@ import org.springframework.stereotype.Component; import com.billpaymentservice.bbps.dto.UserDetailsDTO; import com.billpaymentservice.bbps.dto.auth.RegisterRequest; +import com.billpaymentservice.bbps.dto.response.BillDataResponse; import com.billpaymentservice.bbps.entites.BBPSMastersData; import com.billpaymentservice.bbps.entites.BharatConnectMaster; +import com.billpaymentservice.bbps.entites.BillMaster; import com.billpaymentservice.bbps.entites.InboundTraceLog; import com.billpaymentservice.bbps.entites.OutboundTraceLog; import com.billpaymentservice.bbps.entites.TransactionMaster; @@ -284,5 +286,10 @@ public class Helper { LOGGER.info("TransactionMaster dest after merge: {}", dest); } + public void mergeNonNullFieldsBillIntiate(BillDataResponse responseWrapper, BillMaster existingbill) { + + + } + } \ No newline at end of file diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties index 79e2fdd..5d343ea 100644 --- a/src/main/resources/application-local.properties +++ b/src/main/resources/application-local.properties @@ -23,9 +23,9 @@ swagger.server.description=Local Development Server spring.datasource.url=jdbc:postgresql://localhost:5432/bbps_enhanced spring.datasource.username=postgres -spring.datasource.password=UAT@DB_2025 +#spring.datasource.password=UAT@DB_2025 -#spring.datasource.password=himanshu@123 +spring.datasource.password=himanshu@123 spring.datasource.driver-class-name=org.postgresql.Driver spring.datasource.type=com.zaxxer.hikari.HikariDataSource