```mermaid sequenceDiagram participant User participant PaymentService participant PaymentGateway participant Database %% 정상 흐름 User->>PaymentService: 결제 요청 PaymentService->>PaymentGateway: 결제 요청 PaymentGateway-->>PaymentService: 결제 결과 PaymentService->>Database: 거래 정보 저장 Database-->>PaymentService: 저장 확인 %% 외부 실패 흐름 User->>PaymentService: 결제 요청 PaymentService->>PaymentGateway: 결제 요청 PaymentGateway-->>PaymentService: 결제 실패 PaymentService->>User: 오류 메시지 전송 %% DB 실패 흐름 User->>PaymentService: 결제 요청 PaymentService->>PaymentGateway: 결제 요청 PaymentGateway-->>PaymentService: 결제 결과 PaymentService->>Database: 거래 정보 저장 Database-->>PaymentService: 저장 오류 PaymentService->>User: 오류 메시지 전송 %% commit과 rollback 경계 PaymentService->>Database: 거래 정보 커밋 PaymentGateway-->>PaymentService: 결제 완료 activate PaymentService PaymentService-->>Database: 롤백 요청 deactivate PaymentService ```