Skip to content

[FEATURE] 결제 취소 기능 및 결제 내역 조회 기능 구현#215

Merged
EndlessMilkyway merged 9 commits into
developfrom
feature/211-payment-cancel-and-history-implementation
Aug 6, 2025
Merged

[FEATURE] 결제 취소 기능 및 결제 내역 조회 기능 구현#215
EndlessMilkyway merged 9 commits into
developfrom
feature/211-payment-cancel-and-history-implementation

Conversation

@EndlessMilkyway

Copy link
Copy Markdown
Contributor

관련 Issue (필수)

주요 변경 사항 (필수)

결제 취소 기능 구현

  • PaymentController에 cancelPayment API 엔드포인트 추가 (POST /api/v1/payments/{paymentKey}/cancel)
  • PaymentService에 결제 취소 및 자동 환불 처리 로직 구현
  • 결제 취소 시 예약 상태도 함께 취소로 변경되도록 연동

결제 내역 조회 기능 구현

  • PaymentController에 getPaymentHistory API 엔드포인트 추가 (GET /api/v1/payments)
  • PaymentService에 사용자별 결제 내역 조회 서비스 구현
  • QueryDSL을 활용한 효율적인 데이터 조회 구조 도입
  • PaymentProjection 클래스 구현 (필요한 필드만 조회하는 프로젝션)
  • QueryDSL 기반 리포지토리 레이어 구현 (PaymentRepositoryCustom 인터페이스 및 PaymentRepositoryCustomImpl 구현체 추가)

리뷰어 참고 사항

  1. 결제 취소 및 환불 처리 로직
    결제 취소 시 즉시 환불 처리가 되도록 임시 구현되어 있습니다. 실제 운영에서는 PG사 API 연동이 필요하지만, 현재는 내부적으로 상태만 변경하는 방식으로 구현했습니다.
  2. QueryDSL 도입으로 인한 성능 개선
    결제 내역 조회 시 필요한 필드만 select하는 프로젝션을 사용하여 불필요한 데이터 로딩을 방지했습니다. 특히 연관 엔티티(Member, Reservation)의 모든 필드를 가져오지 않고 필요한 정보만 조회합니다.
  3. 트랜잭션 처리
    결제 취소: @Transactional로 원자성 보장
    결제 내역 조회: @Transactional(readOnly = true)로 읽기 전용 최적화
  4. 보안 및 권한 검증
    결제 취소와 내역 조회 모두 @AuthenticationPrincipal을 통해 로그인 사용자만 접근 가능하며, 본인의 결제 건만 처리할 수 있도록 검증 로직이 포함되어 있습니다.

추가 정보

현재는 즉시 환불 처리되지만, 추후 PG사 API 연동 시 비동기 처리로 변경될 수 있습니다
QueryDSL 프로젝션을 활용하여 N+1 문제를 예방하고 성능을 최적화했습니다

PR 작성 체크리스트 (필수)

  • 제목이 Issue와 동일함을 확인했습니다.
  • 리뷰어를 지정했습니다.
  • 프로젝트를 연결했습니다.

@friox friox left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

결제 과정을 메서드로 잘 분리해놓으셔서 흐름을 따라가는 데 수월했습니다!
코드 아주 깔끔해보입니다! 고생하셨습니다 👍👍

@chanwonlee chanwonlee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

전반적으로 메서드 분리를 깔끔하게 해주셔서 로직을 읽기 편했습니다.
두 분께서 고민하신 서비스 레이어 관련 부분은 저도 한 번쯤 생각해봤던 주제라, 시간이 더 있었다면 이 부분을 함께 개선해볼 수 있었을 텐데 하는 아쉬움이 남습니다... 수고 많으셨습니다!

@Jimin730 Jimin730 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

영렬님은 코드가 정말 깔끔한 것 같습니다..
결제 취소 및 내역 조회에 대한 부분 확인했습니다! 👍
영렬님과 승훈님이 서비스 계층 관련하여 고민을 나누신걸 보니 저도 해당 고민을 한 번 더 생각해볼 수 있어서 좋았습니다 :)

@Yunsung-Jo Yunsung-Jo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다! 👍

@EndlessMilkyway
EndlessMilkyway merged commit 1241d45 into develop Aug 6, 2025
3 checks passed
@EndlessMilkyway
EndlessMilkyway deleted the feature/211-payment-cancel-and-history-implementation branch August 6, 2025 04:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[FEATURE] 결제 취소 기능 및 결제 내역 조회 기능 구현

5 participants