결제 시스템 전반적 로직 개선, 코드 정리#43
Merged
Merged
Conversation
added 10 commits
June 26, 2025 17:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR 타입
구현한 기능
코드 정리 및 책임 분리
사용하지 않는 코드, 불필요한 메서드, 주석 제거로 코드 가독성 개선
Controller에서 비즈니스 로직을 모두 Service로 이관하여 계층별 책임 명확화
API 호출 구조 개선
외부 API 호출 로직을 RestTemplate 유틸로 일관화
→ 중복 제거, 재사용성 및 가독성 향상
외부 API 호출부에 try-catch 예외 처리 추가
→ 실패 시 적절한 공통 에러 코드 반환
→ 장애 발생 시 빠르게 원인 파악 가능 (EXTERNAL_API_ERROR, PAYMENT_FAILED)
트랜잭션 관리 최적화
읽기 전용 메서드에 @transactional(readOnly = true) 적용
→ 불필요한 더티 체킹 방지, 성능 최적화
쓰기/변경 메서드에는 명시적으로 @transactional 적용하여 데이터 일관성 보장
DB 무결성 및 중복 방지
saveTid 시 TID 중복 저장 방지 로직 추가
→ paymentRepository.existsByTid(tid) 체크 후 저장
중복 저장 시 TID_ALREADY_EXIST 에러 코드 반환
결제 상태 관리 개선
정기 결제 상태를 카카오 서버 대신 우리 DB에서 직접 관리하도록 변경
→ 상태를 유저 테이블에서 isSubscribeActive로 관리
→ 카카오 API는 정합성 검증용으로만 호출
정기 결제 스케줄러 개선
유저별 결제일 계산 로직 구현 (결제일 + 새로운 달 체크)
유저가 카카오페이 앱에서 직접 구독 취소 시, 우리 DB에도 반영되도록 스케줄러에서 상태 동기화 추가
결제 실패 시 처리 강화
결제 승인 요청, 정기 결제 요청 등에서 결제 API 호출 실패 시 enableSubscription 호출 방지
→ 결제 성공 응답을 받았을 때만 구독 활성화 처리하도록 수정
커밋 메시지, 코드 스타일, 문서화 일관성 유지
작업 내역을 일관된 커밋 메시지 규칙으로 관리
코드 스타일, 예외 처리, 메서드 작성 방식 모두 프로젝트 컨벤션에 맞춰 정리
일정