updated code

This commit is contained in:
Mohd-Arham
2025-12-11 16:48:00 +05:30
12 changed files with 58 additions and 112 deletions
@@ -11,9 +11,7 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.billpaymentservice.bbps.entites.UserEntity; import com.billpaymentservice.bbps.entites.UserEntity;
import com.billpaymentservice.bbps.entites.UsersDetails;
import com.billpaymentservice.bbps.repository.UserRepository; import com.billpaymentservice.bbps.repository.UserRepository;
import com.billpaymentservice.bbps.repository.UsersDetailsRepository;
@Service @Service
public class CustomUserDetailsService implements UserDetailsService { public class CustomUserDetailsService implements UserDetailsService {
@@ -32,7 +32,7 @@ public class BillPaymentRequest extends BaseClass {
private String customerMobNo; private String customerMobNo;
private String txnAmount; // Changed to @NotNull as it's an Integer (non-nullable) private Integer txnAmount; // Changed to @NotNull as it's an Integer (non-nullable)
private String paymentRefId; private String paymentRefId;
@@ -29,7 +29,7 @@ public class BillPaymentForwardRequest {
private String billerCategory; private String billerCategory;
private String macAdress; private String macAdress;
private String customerMobNo; private String customerMobNo;
private String txnAmount; private Integer txnAmount;
private String paymentRefId; private String paymentRefId;
private String clientReqId; private String clientReqId;
private String paymentChannel; private String paymentChannel;
@@ -14,7 +14,7 @@ import lombok.Setter;
@Setter @Setter
@Entity @Entity
@Table(name = "bbps_bill_customer_params") @Table(name = "bbps_bill_customer_params")
public class BillCustomerParams { public class BillCustomerParams extends Auditable {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -14,52 +14,55 @@ import lombok.Setter;
import lombok.ToString; import lombok.ToString;
@Entity @Entity
@Table(name="bbps_inbound_log_trace") @Getter
@Getter @Setter @NoArgsConstructor @ToString @Setter
@NoArgsConstructor
@ToString
@Table(name = "bbps_inbound_trace_log")
public class InboundTraceLog { public class InboundTraceLog {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
// 🔹 Identifiers // 🔹 Identifiers
@Column(length = 50, unique = true) @Column(length = 50, unique = true)
private String requestId; // external requestId (from client) private String requestId; // external requestId (from client)
@Column(length = 35) @Column(length = 35)
private String txnId; // internally generated transaction id private String txnId; // internally generated transaction id
// 🔹 Source & API info // 🔹 Source & API info
private String orgId; // tumhara org code (like ORG001) private String orgId; // tumhara org code (like ORG001)
private String mid; // merchant id from request private String mid; // merchant id from request
private String apiName; // e.g. getBillerByBillerId private String apiName; // e.g. getBillerByBillerId
private String httpMethod; // GET / POST private String httpMethod; // GET / POST
// 🔹 Request/Response data // 🔹 Request/Response data
@Column(columnDefinition = "TEXT") @Column(columnDefinition = "TEXT")
private String requestPayload; // jo external ne bheja private String requestPayload; // jo external ne bheja
@Column(columnDefinition = "TEXT") @Column(columnDefinition = "TEXT")
private String responsePayload; // jo tumne wapas bheja private String responsePayload; // jo tumne wapas bheja
// 🔹 Status & timing // 🔹 Status & timing
private String status; // SUCCESS / FAILED private String status; // SUCCESS / FAILED
private String responseCode; // like 200, 400 etc. private String responseCode; // like 200, 400 etc.
private LocalDateTime requestTime; // jab request aayi private LocalDateTime requestTime; // jab request aayi
private LocalDateTime responseTime; // jab response gaya private LocalDateTime responseTime; // jab response gaya
private LocalDateTime createdAt = LocalDateTime.now(); private LocalDateTime createdAt = LocalDateTime.now();
@Column(length = 255) @Column(length = 255)
private String remark; // error ya note private String remark; // error ya note
public InboundTraceLog(String requestId, String txnId, String apiName, String mid, public InboundTraceLog(String requestId, String txnId, String apiName, String mid, String orgId, String httpMethod,
String orgId, String httpMethod, String requestPayload) { String requestPayload) {
this.requestId = requestId; this.requestId = requestId;
this.txnId = txnId; this.txnId = txnId;
this.apiName = apiName; this.apiName = apiName;
this.mid = mid; this.mid = mid;
this.orgId = orgId; this.orgId = orgId;
this.httpMethod = httpMethod; this.httpMethod = httpMethod;
this.requestPayload = requestPayload; this.requestPayload = requestPayload;
this.requestTime = LocalDateTime.now(); this.requestTime = LocalDateTime.now();
this.createdAt = LocalDateTime.now(); this.createdAt = LocalDateTime.now();
} }
} }
@@ -14,11 +14,11 @@ import lombok.Setter;
import lombok.ToString; import lombok.ToString;
@Entity @Entity
@Table(name = "bbps_outbound_log_trace") @ToString
@Getter @Getter
@Setter @Setter
@NoArgsConstructor @NoArgsConstructor
@ToString @Table(name = "bbps_outbound_trace_log")
public class OutboundTraceLog { public class OutboundTraceLog {
@Id @Id
@@ -1,38 +0,0 @@
package com.billpaymentservice.bbps.entites;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "bbps_user_details")
public class UsersDetails extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Column(name = "user_email_id")
private String userEmailId;
@Column(name = "user_mob_no")
private String userMobNo;
@Column(name = "user_name")
private String userName;
@Column(name = "user_age")
private String userAge;
}
@@ -1,16 +0,0 @@
package com.billpaymentservice.bbps.repository;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Repository;
import com.billpaymentservice.bbps.entites.UsersDetails;
@Repository
public interface UsersDetailsRepository extends JpaRepository<UsersDetails, Long> {
Optional<UsersDetails> findByUserMobNo(String userMobNo);
}
@@ -20,10 +20,8 @@ import com.billpaymentservice.bbps.dto.auth.UserDto;
import com.billpaymentservice.bbps.dto.auth.VerifyOtpRequest; import com.billpaymentservice.bbps.dto.auth.VerifyOtpRequest;
import com.billpaymentservice.bbps.dto.response.AuthResponses; import com.billpaymentservice.bbps.dto.response.AuthResponses;
import com.billpaymentservice.bbps.entites.UserEntity; import com.billpaymentservice.bbps.entites.UserEntity;
import com.billpaymentservice.bbps.entites.UsersDetails;
import com.billpaymentservice.bbps.exception.CustomException; import com.billpaymentservice.bbps.exception.CustomException;
import com.billpaymentservice.bbps.repository.UserRepository; import com.billpaymentservice.bbps.repository.UserRepository;
import com.billpaymentservice.bbps.repository.UsersDetailsRepository;
import com.billpaymentservice.bbps.service.AuthService; import com.billpaymentservice.bbps.service.AuthService;
import com.billpaymentservice.bbps.util.BBPSConstant; import com.billpaymentservice.bbps.util.BBPSConstant;
import com.billpaymentservice.bbps.util.Helper; import com.billpaymentservice.bbps.util.Helper;
@@ -41,16 +39,13 @@ public class AuthServiceImpl implements AuthService {
private final UserRepository userRepository; private final UserRepository userRepository;
private final OtpClient otpClient; private final OtpClient otpClient;
private final Helper helper; private final Helper helper;
private final UsersDetailsRepository userRepo;
private final JwtUtil jwtUtil; private final JwtUtil jwtUtil;
@Autowired @Autowired
public AuthServiceImpl(UserRepository userRepository, OtpClient otpClient, Helper helper, public AuthServiceImpl(UserRepository userRepository, OtpClient otpClient, Helper helper, JwtUtil jwtUtil) {
UsersDetailsRepository userRepo, JwtUtil jwtUtil) {
this.userRepository = userRepository; this.userRepository = userRepository;
this.otpClient = otpClient; this.otpClient = otpClient;
this.helper = helper; this.helper = helper;
this.userRepo = userRepo;
this.jwtUtil = jwtUtil; this.jwtUtil = jwtUtil;
} }
@@ -49,7 +49,6 @@ import com.billpaymentservice.bbps.entites.DispositionDetails;
import com.billpaymentservice.bbps.entites.InboundTraceLog; import com.billpaymentservice.bbps.entites.InboundTraceLog;
import com.billpaymentservice.bbps.entites.OutboundTraceLog; import com.billpaymentservice.bbps.entites.OutboundTraceLog;
import com.billpaymentservice.bbps.entites.PlanResponses; import com.billpaymentservice.bbps.entites.PlanResponses;
import com.billpaymentservice.bbps.entites.UsersDetails;
import com.billpaymentservice.bbps.exception.CustomException; import com.billpaymentservice.bbps.exception.CustomException;
import com.billpaymentservice.bbps.repository.BharatConnectMasterRepository; import com.billpaymentservice.bbps.repository.BharatConnectMasterRepository;
import com.billpaymentservice.bbps.repository.BillerDataRepository; import com.billpaymentservice.bbps.repository.BillerDataRepository;
@@ -58,7 +57,6 @@ import com.billpaymentservice.bbps.repository.DispositionRepository;
import com.billpaymentservice.bbps.repository.InboundTraceLogRepository; import com.billpaymentservice.bbps.repository.InboundTraceLogRepository;
import com.billpaymentservice.bbps.repository.MerchantRepository; import com.billpaymentservice.bbps.repository.MerchantRepository;
import com.billpaymentservice.bbps.repository.OutboundTraceLogRepository; import com.billpaymentservice.bbps.repository.OutboundTraceLogRepository;
import com.billpaymentservice.bbps.repository.UsersDetailsRepository;
import com.billpaymentservice.bbps.service.MasterDataService; import com.billpaymentservice.bbps.service.MasterDataService;
import com.billpaymentservice.bbps.util.BBPSConstant; import com.billpaymentservice.bbps.util.BBPSConstant;
import com.billpaymentservice.bbps.util.BillerMapperHelper; import com.billpaymentservice.bbps.util.BillerMapperHelper;
@@ -138,9 +138,15 @@ public class PaymentServiceImpl implements PaymentService {
LOGGER.warn("Invalid response structure received for txnId={}", txnId); LOGGER.warn("Invalid response structure received for txnId={}", txnId);
throw new CustomException(BBPSConstant.INVALID_STRUCTURE); throw new CustomException(BBPSConstant.INVALID_STRUCTURE);
} }
BillPaymentResponse billPaymentResponse = objectMapper.convertValue(dataMap, BillPaymentResponse.class); BillPaymentResponse billPaymentResponse = objectMapper.convertValue(dataMap, BillPaymentResponse.class);
GeneralResp generalResponse = billPaymentResponse.getGenericResponse(); GeneralResp generalResponse = billPaymentResponse.getGenericResponse();
LOGGER.info("genric Response" + generalResponse);
if(generalResponse.getStatus().equalsIgnoreCase("Failed")) {
throw new CustomException(generalResponse.getMessage(), generalResponse.getStatus(),
Integer.parseInt(generalResponse.getStatusCode()), generalResponse.getRemarks());
}
BillPayment entity = modelMapper.map(billPaymentResponse, BillPayment.class); BillPayment entity = modelMapper.map(billPaymentResponse, BillPayment.class);
paymentRepository.save(entity); paymentRepository.save(entity);
@@ -303,7 +303,7 @@ public class PaymentStartServiceImpl implements PaymentStartService {
rd.setAmount(parsedAmount != null && !parsedAmount.isEmpty() ? parsedAmount : "0.00"); rd.setAmount(parsedAmount != null && !parsedAmount.isEmpty() ? parsedAmount : "0.00");
rd.setMid(parsedMid); rd.setMid(parsedMid);
rd.setOrderNo(orderNo); rd.setOrderNo(orderNo);
rd.setQrString("NO_QR"); rd.setQrString("HTML_RESPONSE");
rd.setCreatedOn(LocalDateTime.now().toString()); rd.setCreatedOn(LocalDateTime.now().toString());
apiResp.setResponseData(rd); apiResp.setResponseData(rd);