@@ -6,6 +6,7 @@ import org.springframework.http.HttpStatus;
|
|||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import ru.soune.nocopy.entity.payment.Payment;
|
import ru.soune.nocopy.entity.payment.Payment;
|
||||||
|
import ru.soune.nocopy.exception.PaymentNotFoundException;
|
||||||
import ru.soune.nocopy.exception.TariffNotFoundException;
|
import ru.soune.nocopy.exception.TariffNotFoundException;
|
||||||
import ru.soune.nocopy.exception.UserNotFoundException;
|
import ru.soune.nocopy.exception.UserNotFoundException;
|
||||||
import ru.soune.nocopy.service.payment.PaymentService;
|
import ru.soune.nocopy.service.payment.PaymentService;
|
||||||
@@ -46,7 +47,7 @@ public class PaymentController {
|
|||||||
public void handleYooKassaNotification(@RequestBody Map<String, Object> notification) {
|
public void handleYooKassaNotification(@RequestBody Map<String, Object> notification) {
|
||||||
try {
|
try {
|
||||||
paymentService.handlePaymentNotification(notification);
|
paymentService.handlePaymentNotification(notification);
|
||||||
} catch (Exception e) {
|
} catch (PaymentNotFoundException e) {
|
||||||
log.error("Error processing payment notification", e);
|
log.error("Error processing payment notification", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public class PaymentService {
|
|||||||
String paymentUuid = (String) object.get("id");
|
String paymentUuid = (String) object.get("id");
|
||||||
|
|
||||||
Payment payment = paymentRepository.findByPaymentUuid(paymentUuid)
|
Payment payment = paymentRepository.findByPaymentUuid(paymentUuid)
|
||||||
.orElseThrow(() -> new RuntimeException("Payment not found"));
|
.orElseThrow(() -> new PaymentNotFoundException("Payment not found"));
|
||||||
|
|
||||||
if ("payment.succeeded".equals(eventType)) {
|
if ("payment.succeeded".equals(eventType)) {
|
||||||
payment.setStatus(PaymentStatus.SUCCEEDED);
|
payment.setStatus(PaymentStatus.SUCCEEDED);
|
||||||
|
|||||||
Reference in New Issue
Block a user