34 lines
1.1 KiB
Java
34 lines
1.1 KiB
Java
package ru.soune.nocopy.controller;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import ru.soune.nocopy.entity.payment.Payment;
|
|
import ru.soune.nocopy.service.payment.PaymentService;
|
|
|
|
import java.util.Map;
|
|
|
|
@RestController
|
|
@RequestMapping("/api/payments")
|
|
@RequiredArgsConstructor
|
|
@Slf4j
|
|
public class PaymentController {
|
|
|
|
private final PaymentService paymentService;
|
|
|
|
@PostMapping("/create")
|
|
public Payment createPayment(@RequestParam String email, @RequestParam Long tariffId,
|
|
@RequestParam String operationType, @RequestParam String operationUuid) {
|
|
return paymentService.createPayment(email, tariffId, operationType, operationUuid);
|
|
}
|
|
|
|
@PostMapping("webhook/yookassa")
|
|
public void handleYooKassaNotification(@RequestBody Map<String, Object> notification) {
|
|
try {
|
|
paymentService.handlePaymentNotification(notification);
|
|
} catch (Exception e) {
|
|
log.error("Error processing payment notification", e);
|
|
}
|
|
}
|
|
}
|