dev add api for payment
Test Workflow / test (push) Successful in 11s

This commit is contained in:
vladp
2026-02-18 19:00:44 +07:00
parent e2f22bb27b
commit 22a44d833e
2 changed files with 12 additions and 5 deletions
@@ -44,6 +44,7 @@ public enum MessageCode {
RESOURCE_NOT_FOUND(4, "Resource not found"),
INTERNAL_ERROR(4, "Internal server error"),
COMPANY_NOT_FOUND(4, "Company not found"),
PAYMENT_NOT_FOUND(4, "Payment not found"),
COMPANY_ALREADY_EXISTS(2, "Company already exists"),
USER_LIMIT_IS_OVER(2, "Over user limits"),
ERROR_TARIFF_INFO(2, "Erorr with tariff info"),
@@ -9,9 +9,11 @@ import ru.soune.nocopy.dto.MessageCode;
import ru.soune.nocopy.dto.payment.PaymentRequest;
import ru.soune.nocopy.dto.payment.PaymentResponse;
import ru.soune.nocopy.entity.payment.Payment;
import ru.soune.nocopy.exception.PaymentNotFoundException;
import ru.soune.nocopy.service.payment.PaymentService;
import java.util.List;
import java.util.Map;
@Component
@RequiredArgsConstructor
@@ -33,11 +35,15 @@ public class PaymentHandler implements RequestHandler{
return new BaseResponse(request.getMsgId(), MessageCode.SUCCESS.getCode(),
MessageCode.SUCCESS.getDescription(), new PaymentResponse(payments));
case "payment_info":
try {
Payment payment = paymentService.paymentInfo(paymentRequest.getPaymentUuid());
return new BaseResponse(request.getMsgId(), MessageCode.SUCCESS.getCode(),
MessageCode.SUCCESS.getDescription(), new PaymentResponse(List.of(payment)));
} catch (PaymentNotFoundException e) {
return new BaseResponse(request.getMsgId(), MessageCode.PAYMENT_NOT_FOUND.getCode(),
MessageCode.PAYMENT_NOT_FOUND.getDescription(), Map.of("paymentUuid",
paymentRequest.getPaymentUuid()));
}
}
return null;