Skip to content

Comments

fix: 결제 실패 후 reservation session 처리 - #238#239

Merged
sjk4618 merged 4 commits intodevfrom
fix/#238
Feb 4, 2026
Merged

fix: 결제 실패 후 reservation session 처리 - #238#239
sjk4618 merged 4 commits intodevfrom
fix/#238

Conversation

@sjk4618
Copy link
Member

@sjk4618 sjk4618 commented Feb 4, 2026

🔥Pull requests

⛳️ 작업한 브랜치

👷 작업한 내용

  • 결제 실패 후 reservation session 처리(중복 redis rollback)
  • filter log 추가

🚨 참고 사항

@coderabbitai
Copy link

coderabbitai bot commented Feb 4, 2026

📝 Walkthrough

Summary by CodeRabbit

릴리스 노트

  • 버그 수정

    • 결제 실패 처리 시 예약 세션 자동 정리 동작이 더 많은 실패 경로에 걸쳐 일관되게 수행되도록 확장됨.
  • Chores

    • 오류 로깅 포맷 개선 및 관련 필터에 대한 로깅 지원이 추가되어 로그 정보가 더 풍부해짐.

Walkthrough

결제 실패 시 reservation session을 orderId로 삭제하도록 ReservationSessionRemover를 주입·호출하는 로직을 PaymentService에 추가하고, Discord 에러 로거와 필터들에 로깅/포맷 변경을 적용했습니다.

Changes

Cohort / File(s) Summary
PaymentService 변경
src/main/java/com/permitseoul/permitserver/domain/payment/api/service/PaymentService.java
ReservationSessionRemover 의존성 추가(필드·생성자), 실패 예외 처리(catch) 경로에서 redis 롤백 후 deleteReservationSessionByOrderId(orderId) 호출 추가 및 중앙화된 헬퍼 메서드 도입.
Reservation session 삭제 기능
src/main/java/com/permitseoul/permitserver/domain/reservationsession/core/component/ReservationSessionRemover.java, src/main/java/com/permitseoul/permitserver/domain/reservationsession/core/repository/ReservationSessionRepository.java
Repository에 deleteByOrderId(String) 메서드 추가 및 Remover에 deleteByOrderId 트랜잭셔널 메서드 추가.
Discord 에러 로거 리팩토링
src/main/java/com/permitseoul/permitserver/global/DiscordErrorLogAppender.java
buildContentbuildEmbedJson로 변경, JSON embed 페이로드 생성으로 전환, 타임스탬프(KST) 포맷·로거명 단축·메시지·스택트레이스 길이 제한 등 포맷 로직 대체 및 보강.
필터들에 로깅 추가
src/main/java/com/permitseoul/permitserver/global/filter/ExceptionHandlerFilter.java, src/main/java/com/permitseoul/permitserver/global/filter/JwtAuthenticationFilter.java
두 필터에 SLF4J 로깅 추가(클래스 어노테이션/로그 호출). 예외 처리 경로에서 User-Agent 및 예외 정보를 로깅하도록 변경.

Sequence Diagram

sequenceDiagram
    participant Client
    participant PaymentService
    participant ReservationSessionRemover
    participant ReservationSessionRepository
    participant Database

    Client->>PaymentService: getPaymentConfirm()/cancelPayment()
    PaymentService->>PaymentService: 결제 처리 시도
    alt 예외 발생 (ReservationNotFound, EventNotFound, TicketType... 등)
        PaymentService->>PaymentService: redis 롤백
        PaymentService->>PaymentService: deleteReservationSessionByOrderId(orderId)
        PaymentService->>ReservationSessionRemover: deleteByOrderId(orderId)
        ReservationSessionRemover->>ReservationSessionRepository: deleteByOrderId(orderId)
        ReservationSessionRepository->>Database: DELETE FROM reservation_session WHERE order_id = ?
        Database-->>ReservationSessionRepository: 삭제 완료
        ReservationSessionRepository-->>ReservationSessionRemover: 완료
        ReservationSessionRemover-->>PaymentService: 완료
        PaymentService-->>Client: 예외 반환
    else 정상 처리
        PaymentService-->>Client: 결과 반환
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning PR에 #238 범위를 벗어난 filter log 추가(ExceptionHandlerFilter, JwtAuthenticationFilter)와 DiscordErrorLogAppender 리팩토링이 포함되어 있습니다. filter log 추가 및 DiscordErrorLogAppender 리팩토링은 별도 PR로 분리하거나 #238 범위에 포함시키는 명확한 근거를 제시해야 합니다.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 주요 변경 사항인 결제 실패 후 reservation session 처리를 명확하게 설명합니다.
Description check ✅ Passed PR 설명이 결제 실패 후 reservation session 처리 및 filter log 추가와 관련이 있으며 작업 내용을 설명합니다.
Linked Issues check ✅ Passed PR은 #238의 요구사항인 결제 실패 시 reservation session 정리 및 중복 Redis rollback 방지를 구현했습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/#238

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/com/permitseoul/permitserver/global/DiscordErrorLogAppender.java (1)

52-159: ⚠️ Potential issue | 🟡 Minor

Discord 필드 길이 제한을 고려해 메시지/스택 길이를 조정하세요.

Discord embed 필드 값은 최대 1024자로 제한됩니다. 현재 코드는 메시지에 코드펜스(```)를 추가하면 제한을 초과합니다. 예를 들어, 메시지가 1024자로 잘려도 ````로 감싸면 총 1030자가 되어 webhook이 거부될 수 있습니다.

코드펜스 오버헤드(6자)를 고려하여 안전한 상한으로 조정하세요.

🔧 수정 제안(diff)
-        // 메시지 처리 (최대 1024자)
-        String message = event.getFormattedMessage();
-        if (message.length() > 1024) {
-            message = message.substring(0, 1021) + "...";
-        }
+        // 메시지 처리 (Discord field value: 1024 제한 고려)
+        String message = event.getFormattedMessage();
+        final int maxFieldValue = 1024;
+        final int codeFenceOverhead = 6; // ``` ```
+        final int ellipsisOverhead = 3;  // ...
+        final int maxMessageLength = maxFieldValue - codeFenceOverhead;
+        if (message.length() > maxMessageLength) {
+            message = message.substring(0, maxMessageLength - ellipsisOverhead) + "...";
+        }
@@
-            final int maxStackLength = 1000;
+            final int maxStackLength =
+                    maxFieldValue - codeFenceOverhead - "\n... (truncated)".length();
🤖 Fix all issues with AI agents
In
`@src/main/java/com/permitseoul/permitserver/domain/payment/api/service/PaymentService.java`:
- Around line 266-268: The deletion of reservation session inside
deleteReservationSessionByOrderId should be best‑effort and must not overwrite
upstream exceptions; wrap the call to
reservationSessionRemover.deleteByOrderId(orderId) in a try/catch (e.g., catch
Exception or RuntimeException), log the failure with context (include orderId
and the caught exception) and do not rethrow so the original exception mapping
is preserved—adjust the body of deleteReservationSessionByOrderId accordingly to
swallow/log deletion errors only.

@sjk4618 sjk4618 merged commit eb3085b into dev Feb 4, 2026
2 checks passed
@sjk4618 sjk4618 deleted the fix/#238 branch February 4, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: 결제 실패 후 reservation session 처리

1 participant