@@ -90,9 +90,8 @@ public class PaymentService {
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public List<PaymentMethodDTO> getUserPaymentMethods(String email) {
|
||||
User user = userRepository.findByEmail(email);
|
||||
if (user == null) throw new UserNotFoundException(email);
|
||||
public List<PaymentMethodDTO> getUserPaymentMethods(Long userId) {
|
||||
User user = userRepository.findById(userId).orElseThrow();
|
||||
|
||||
return paymentMethodRepository.findByUserAndActiveTrue(user)
|
||||
.stream()
|
||||
@@ -107,10 +106,8 @@ public class PaymentService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deletePaymentMethod(String email, String paymentMethodId) {
|
||||
User user = userRepository.findByEmail(email);
|
||||
if (user == null) throw new UserNotFoundException(email);
|
||||
|
||||
public void deletePaymentMethod(Long userId, String paymentMethodId) {
|
||||
User user = userRepository.findById(userId).orElseThrow();
|
||||
PaymentMethod pm = paymentMethodRepository.findByPaymentMethodId(paymentMethodId)
|
||||
.orElseThrow(() -> new RuntimeException("Payment method not found"));
|
||||
|
||||
@@ -123,9 +120,8 @@ public class PaymentService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void disableAutoRenewal(String email) {
|
||||
User user = userRepository.findByEmail(email);
|
||||
if (user == null) throw new UserNotFoundException(email);
|
||||
public void disableAutoRenewal(Long userId) {
|
||||
User user = userRepository.findById(userId).orElseThrow();
|
||||
|
||||
TariffInfo tariffInfo = user.getActiveTariffInfo();
|
||||
if (tariffInfo != null) {
|
||||
|
||||
Reference in New Issue
Block a user