File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
src/main/java/com/sumte/payment/kakaopay Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change 66import com .sumte .payment .dto .KakaoPayReadyRequestDTO ;
77import com .sumte .payment .dto .KakaoPayReadyResponseDTO ;
88import lombok .RequiredArgsConstructor ;
9+ import lombok .extern .slf4j .Slf4j ;
910import org .springframework .beans .factory .annotation .Value ;
11+ import org .springframework .http .HttpStatusCode ;
1012import org .springframework .stereotype .Component ;
1113import org .springframework .web .reactive .function .client .WebClient ;
14+ import reactor .core .publisher .Mono ;
1215
1316@ Component
1417@ RequiredArgsConstructor
18+ @ Slf4j
1519public class KakaoPayClient {
1620
1721 private final WebClient webClient ;
@@ -27,6 +31,12 @@ public KakaoPayReadyResponseDTO requestPayment(KakaoPayReadyRequestDTO request)
2731 .header ("Content-Type" , "application/json" )
2832 .bodyValue (request )
2933 .retrieve ()
34+ .onStatus (HttpStatusCode ::isError , res ->
35+ res .bodyToMono (String .class ).flatMap (body -> {
36+ log .info ("KakaoPay READY {} body: {}" , res .statusCode (), body ); // 핵심!
37+ return Mono .error (new IllegalStateException ("KakaoPay ready error: " + body ));
38+ })
39+ )
3040 .bodyToMono (KakaoPayReadyResponseDTO .class )
3141 .block ();
3242 }
You can’t perform that action at this time.
0 commit comments