diff --git a/src/main/java/ru/soune/nocopy/controller/PaymentController.java b/src/main/java/ru/soune/nocopy/controller/PaymentController.java index 1c29804..42faa55 100644 --- a/src/main/java/ru/soune/nocopy/controller/PaymentController.java +++ b/src/main/java/ru/soune/nocopy/controller/PaymentController.java @@ -6,6 +6,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import ru.soune.nocopy.entity.payment.Payment; +import ru.soune.nocopy.exception.PaymentNotFoundException; import ru.soune.nocopy.exception.TariffNotFoundException; import ru.soune.nocopy.exception.UserNotFoundException; import ru.soune.nocopy.service.payment.PaymentService; @@ -46,7 +47,7 @@ public class PaymentController { public void handleYooKassaNotification(@RequestBody Map notification) { try { paymentService.handlePaymentNotification(notification); - } catch (Exception e) { + } catch (PaymentNotFoundException e) { log.error("Error processing payment notification", e); } } diff --git a/src/main/java/ru/soune/nocopy/service/payment/PaymentService.java b/src/main/java/ru/soune/nocopy/service/payment/PaymentService.java index 163a7c8..7030802 100644 --- a/src/main/java/ru/soune/nocopy/service/payment/PaymentService.java +++ b/src/main/java/ru/soune/nocopy/service/payment/PaymentService.java @@ -67,7 +67,7 @@ public class PaymentService { String paymentUuid = (String) object.get("id"); Payment payment = paymentRepository.findByPaymentUuid(paymentUuid) - .orElseThrow(() -> new RuntimeException("Payment not found")); + .orElseThrow(() -> new PaymentNotFoundException("Payment not found")); if ("payment.succeeded".equals(eventType)) { payment.setStatus(PaymentStatus.SUCCEEDED);