File tree Expand file tree Collapse file tree
apps/commerce-api/src/main/java/com/loopers/application/payment Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33import com .loopers .infrastructure .payment .client .PgClient ;
44import com .loopers .interfaces .api .ApiResponse ;
55import com .loopers .interfaces .api .payment .PaymentV1Dto ;
6+ import io .github .resilience4j .circuitbreaker .annotation .CircuitBreaker ;
67import lombok .RequiredArgsConstructor ;
78import org .springframework .stereotype .Component ;
89
1112public class PaymentFacade {
1213 private final PgClient pgClient ;
1314
14- public PaymentV1Dto .TransactionResponse pay (String userId , PaymentV1Dto .PaymentRequest request ) {
15+ @ CircuitBreaker (name = "pgCircuit" , fallbackMethod = "fallback" )
16+ public PaymentV1Dto .TransactionResponse requestPayment (String userId , PaymentV1Dto .PaymentRequest request ) {
1517 ApiResponse <PaymentV1Dto .TransactionResponse > result = pgClient .requestPayment (userId , request );
1618
1719 PaymentV1Dto .TransactionResponse response = result .data ();
1820
1921 return response ;
2022 }
23+
24+ public PaymentV1Dto .TransactionResponse fallback (String userId , PaymentV1Dto .PaymentRequest request , Throwable throwable ) {
25+ return new PaymentV1Dto .TransactionResponse (
26+ null ,
27+ PaymentV1Dto .TransactionStatusResponse .FAILED ,
28+ "현재 결제 서비스가 불안정합니다. 잠시 후 다시 시도해주세요."
29+ );
30+ }
2131}
You can’t perform that action at this time.
0 commit comments