@@ -11,6 +11,7 @@ import ru.soune.nocopy.entity.tarif.TariffInfo;
|
||||
import ru.soune.nocopy.entity.tarif.TariffStatus;
|
||||
import ru.soune.nocopy.entity.user.User;
|
||||
import ru.soune.nocopy.exception.PaymentNotFoundException;
|
||||
import ru.soune.nocopy.exception.TariffNotFoundException;
|
||||
import ru.soune.nocopy.exception.UserNotFoundException;
|
||||
import ru.soune.nocopy.repository.PaymentRepository;
|
||||
import ru.soune.nocopy.repository.TariffRepository;
|
||||
@@ -35,7 +36,13 @@ public class PaymentService {
|
||||
@Transactional
|
||||
public Payment createPayment(String email, Long tariffId, String operationType, String paymentUuid) {
|
||||
User user = userRepository.findByEmail(email);
|
||||
Tariff tariff = tariffRepository.findById(tariffId).orElseThrow();
|
||||
|
||||
if (user == null) {
|
||||
throw new UserNotFoundException(email);
|
||||
}
|
||||
|
||||
Tariff tariff = tariffRepository.findById(tariffId).orElseThrow(() ->
|
||||
new TariffNotFoundException("Tariff not found"));
|
||||
|
||||
Payment payment = new Payment();
|
||||
payment.setStatus(PaymentStatus.PENDING);
|
||||
|
||||
Reference in New Issue
Block a user