Conversation
Pull Request Review: Payment System ImplementationOverviewThis PR introduces a comprehensive payment system integration with TossPayments, including order management, cart improvements, and monitoring infrastructure. The changes span 37 files with significant refactoring of payment and order flows. Code Quality & Best Practices ✅Strengths:
Areas for Improvement:1. Spring Boot Version Downgrade - id 'org.springframework.boot' version '3.5.5'
+ id 'org.springframework.boot' version '3.2.5'Issue: Downgrading from 3.5.5 to 3.2.5 loses bug fixes and security patches. 2. Missing @PostMapping("/confirm/payment")
public ResponseEntity<JSONObject> confirmPayment(...)Issue: The Security Concerns 🔒Critical Issues:1. Payment Amount Validation if (!order.getTotalAmount().equals(requestDto.getAmount().intValue())) {
throw new RuntimeException("주문 금액이 일치하지 않습니다.");
}Good: Amount validation prevents price manipulation // TODO: 금액 위변조 시도가 의심되므로 결제 취소 API를 호출하는 로직 추가 필요2. Input Validation Missing @Getter @Setter
public class PaymentConfirmRequestDto {
private String paymentKey; // Should be @NotBlank
private String orderId; // Should be @NotBlank
private Long amount; // Should be @NotNull @Positive
}Recommendation: Add Jakarta Bean Validation: @NotBlank(message = "결제 키는 필수입니다")
private String paymentKey;
@NotNull @Positive
private Long amount;3. API Key Exposure Risk @Value("${toss.secret.key}")
private String API_SECRET_KEY;Good: Using externalized configuration Potential Bugs 🐛1. Race Condition in Order Creation for (CartItem cartItem : cartItems) {
if (cartItem.getProduct().getStock() < cartItem.getQuantity()) {
throw new RuntimeException("재고가 부족한 상품이 있습니다: " + cartItem.getProduct().getName());
}
}
// ... later, stock is decreased in confirmPayment()Issue: Stock is checked but NOT reserved. Between
Recommendation: Use optimistic locking (already implemented in 2. Unchecked Type Cast 3. Cart Item Removal Logic cart.getCartItems().removeAll(itemsToRemove);Concern: This relies on JPA's @OneToMany(mappedBy = "cart", cascade = CascadeType.ALL, orphanRemoval = true)
private List<CartItem> cartItems;Performance Considerations ⚡1. N+1 Query Problem - Acknowledged ✅ // N+1 문제 발생 버전 (테스트용)
Cart cart = cartRepository.findByMemberId(member.getId())Good: Explicitly documented for testing
2. Synchronous Payment Confirmation 3. Missing Database Indexes
Test Coverage 📊Good:
Missing:
Recommendation: Add tests for: @Test
void shouldRejectDuplicatePaymentConfirmation() { ... }
@Test
void shouldHandleTossPaymentsAPIFailure() { ... }
@Test
void shouldPreventNegativeStockAfterConcurrentOrders() { ... }Monitoring & Observability ✅Excellent Additions:
Recommendations:
Architecture Improvements 🏗️What I Like:
Suggestions:
SummaryApprove with Recommendations ✅ This is a solid implementation of a payment system with good separation of concerns and proper DTO usage. The main concerns are:
Security: Generally good, but needs validation annotations Great work on the monitoring setup and DTO refactoring! 🚀 |
No description provided.