From 0fc537da93050df9335e65d46a1b341782d469b9 Mon Sep 17 00:00:00 2001 From: pricelees Date: Sun, 17 Aug 2025 21:17:22 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20TosspaymentClient=20=EB=82=B4=20?= =?UTF-8?q?=EC=84=B1=EA=B3=B5=20=EB=A1=9C=EA=B9=85=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/v2/TosspaymentClientV2.kt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/roomescape/payment/infrastructure/client/v2/TosspaymentClientV2.kt b/src/main/kotlin/roomescape/payment/infrastructure/client/v2/TosspaymentClientV2.kt index 0d0310f7..35816231 100644 --- a/src/main/kotlin/roomescape/payment/infrastructure/client/v2/TosspaymentClientV2.kt +++ b/src/main/kotlin/roomescape/payment/infrastructure/client/v2/TosspaymentClientV2.kt @@ -26,15 +26,19 @@ class TosspaymentClientV2( private val cancelClient = CancelClient(objectMapper, tossPaymentClientBuilder.build()) fun confirm(request: PaymentConfirmRequest): PaymentConfirmResponse { - log.info { "[TossPaymentClientV2.confirm] 승인 요청: request=$request" } + log.info { "[TossPaymentClientV2.confirm] 결제 승인 요청: request=$request" } - return confirmClient.request(request) + return confirmClient.request(request).also { + log.info { "[TossPaymentClientV2.confirm] 결제 승인 완료: response=$it" } + } } fun cancel(request: PaymentCancelRequestV2): PaymentCancelResponseV2 { - log.info { "[TossPaymentClient.cancel] 취소 요청: request=$request" } + log.info { "[TossPaymentClient.cancel] 결제 취소 요청: request=$request" } - return cancelClient.request(request) + return cancelClient.request(request).also { + log.info { "[TossPaymentClient.cancel] 결제 취소 완료: response=$it" } + } } } @@ -54,8 +58,7 @@ private class ConfirmClient( .body(request) .retrieve() .onStatus(errorHandler) - .body(PaymentConfirmResponse::class.java) - ?: run { + .body(PaymentConfirmResponse::class.java) ?: run { log.error { "[TossPaymentConfirmClient.request] 응답 바디 변환 실패" } throw PaymentException(PaymentErrorCode.PAYMENT_UNEXPECTED_ERROR) } @@ -103,7 +106,7 @@ private class TosspayErrorHandler( response: ClientHttpResponse ): Nothing { val requestType: String = paymentRequestType(url) - log.warn { "[TossPaymentClient] $requestType 요청 실패: response: ${toErrorResponse(response)}" } + log.warn { "[TossPaymentClient] $requestType 요청 실패: response: ${parseResponse(response)}" } throw PaymentException(paymentErrorCode(response.statusCode)) } @@ -123,7 +126,7 @@ private class TosspayErrorHandler( PaymentErrorCode.PAYMENT_PROVIDER_ERROR } - private fun toErrorResponse(response: ClientHttpResponse): TossPaymentErrorResponse { + private fun parseResponse(response: ClientHttpResponse): TossPaymentErrorResponse { val body = response.body return objectMapper.readValue(body, TossPaymentErrorResponse::class.java).also {