sequenceDiagram participant User participant Controller participant Service participant Repository participant Database participant ExternalGateway User->>Controller: 결제 요청 Controller->>Service: 결제 처리 요청 Service->>Repository: 결제 정보 저장 요청 Repository->>Database: 결제 정보 저장 Database-->>Repository: 저장 성공 Repository-->>Service: 저장 성공 Service->>ExternalGateway: 외부 결제 처리 요청 ExternalGateway-->>Service: 성공 응답 Service-->>Controller: 결제 성공 응답 Controller-->>User: 결제 완료 응답 %% DB 실패 흐름 alt DB 실패 Repository-->>Service: 저장 실패 응답 Service-->>Controller: 오류 반환 Controller-->>User: 결제 실패 응답 end %% 외부 실패 흐름 alt 외부 서비스 실패 Service->>ExternalGateway: 외부 결제 처리 요청 ExternalGateway-->>Service: 실패 응답 Service-->>Controller: 오류 반환 Controller-->>User: 결제 실패 응답 end %% Commit/Rollback 경계 note over Repository: 만약 저장이 성공하면 commit note over Repository: 만약 저장이 실패하면 rollback