From 752943a9f71aefca431c28208e500facc9556c20 Mon Sep 17 00:00:00 2001 From: pricelees Date: Sun, 7 Sep 2025 22:22:07 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20Tosspayment=20->=20Tosspay=20=EB=84=A4?= =?UTF-8?q?=EC=9D=B4=EB=B0=8D=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../payment/business/PaymentService.kt | 4 +-- .../infrastructure/client/TosspayClient.kt | 26 +++++++++---------- .../client/TosspayErrorResponse.kt | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/kotlin/roomescape/payment/business/PaymentService.kt b/src/main/kotlin/roomescape/payment/business/PaymentService.kt index 2219bbbc..32f43b64 100644 --- a/src/main/kotlin/roomescape/payment/business/PaymentService.kt +++ b/src/main/kotlin/roomescape/payment/business/PaymentService.kt @@ -9,7 +9,7 @@ import roomescape.payment.exception.PaymentErrorCode import roomescape.payment.exception.PaymentException import roomescape.payment.infrastructure.client.PaymentClientCancelResponse import roomescape.payment.infrastructure.client.PaymentClientConfirmResponse -import roomescape.payment.infrastructure.client.TosspaymentClient +import roomescape.payment.infrastructure.client.TosspayClient import roomescape.payment.infrastructure.persistence.CanceledPaymentEntity import roomescape.payment.infrastructure.persistence.CanceledPaymentRepository import roomescape.payment.infrastructure.persistence.PaymentDetailEntity @@ -28,7 +28,7 @@ private val log: KLogger = KotlinLogging.logger {} @Service class PaymentService( - private val paymentClient: TosspaymentClient, + private val paymentClient: TosspayClient, private val paymentRepository: PaymentRepository, private val paymentDetailRepository: PaymentDetailRepository, private val canceledPaymentRepository: CanceledPaymentRepository, diff --git a/src/main/kotlin/roomescape/payment/infrastructure/client/TosspayClient.kt b/src/main/kotlin/roomescape/payment/infrastructure/client/TosspayClient.kt index f1c4298b..02e32c1c 100644 --- a/src/main/kotlin/roomescape/payment/infrastructure/client/TosspayClient.kt +++ b/src/main/kotlin/roomescape/payment/infrastructure/client/TosspayClient.kt @@ -17,23 +17,23 @@ import java.net.URI private val log: KLogger = KotlinLogging.logger {} @Component -class TosspaymentClient( +class TosspayClient( objectMapper: ObjectMapper, - tossPaymentClientBuilder: RestClient.Builder + tosspayClientBuilder: RestClient.Builder ) { - private val confirmClient = ConfirmClient(objectMapper, tossPaymentClientBuilder.build()) - private val cancelClient = CancelClient(objectMapper, tossPaymentClientBuilder.build()) + private val confirmClient = ConfirmClient(objectMapper, tosspayClientBuilder.build()) + private val cancelClient = CancelClient(objectMapper, tosspayClientBuilder.build()) fun confirm( paymentKey: String, orderId: String, amount: Int, ): PaymentClientConfirmResponse { - log.info { "[TossPaymentClient.confirm] 결제 승인 요청: paymentKey=$paymentKey, orderId=$orderId, amount=$amount" } + log.info { "[TosspayClient.confirm] 결제 승인 요청: paymentKey=$paymentKey, orderId=$orderId, amount=$amount" } return confirmClient.request(paymentKey, orderId, amount) .also { - log.info { "[TossPaymentClient.confirm] 결제 승인 완료: response=$it" } + log.info { "[TosspayClient.confirm] 결제 승인 완료: response=$it" } } } @@ -43,10 +43,10 @@ class TosspaymentClient( amount: Int, cancelReason: String ): PaymentClientCancelResponse { - log.info { "[TossPaymentClient.cancel] 결제 취소 요청: paymentKey=$paymentKey, amount=$amount, cancelReason=$cancelReason" } + log.info { "[TosspayClient.cancel] 결제 취소 요청: paymentKey=$paymentKey, amount=$amount, cancelReason=$cancelReason" } return cancelClient.request(paymentKey, amount, cancelReason).also { - log.info { "[TossPaymentClient.cancel] 결제 취소 완료: response=$it" } + log.info { "[TosspayClient.cancel] 결제 취소 완료: response=$it" } } } } @@ -75,7 +75,7 @@ private class ConfirmClient( .onStatus(errorHandler) .body(PaymentClientConfirmResponse::class.java) ?: run { - log.error { "[TossPaymentConfirmClient.request] 응답 바디 변환 실패" } + log.error { "[TosspayConfirmClient.request] 응답 바디 변환 실패" } throw PaymentException(PaymentErrorCode.PAYMENT_UNEXPECTED_ERROR) } } @@ -106,7 +106,7 @@ private class CancelClient( .onStatus(errorHandler) .body(PaymentClientCancelResponse::class.java) ?: run { - log.error { "[TossPaymentClient] 응답 바디 변환 실패" } + log.error { "[TosspayClient] 응답 바디 변환 실패" } throw PaymentException(PaymentErrorCode.PAYMENT_UNEXPECTED_ERROR) } } @@ -126,7 +126,7 @@ private class TosspayErrorHandler( response: ClientHttpResponse ): Nothing { val requestType: String = paymentRequestType(url) - log.warn { "[TossPaymentClient] $requestType 요청 실패: response: ${parseResponse(response)}" } + log.warn { "[TosspayClient] $requestType 요청 실패: response: ${parseResponse(response)}" } throw PaymentException(paymentErrorCode(response.statusCode)) } @@ -146,10 +146,10 @@ private class TosspayErrorHandler( PaymentErrorCode.PAYMENT_PROVIDER_ERROR } - private fun parseResponse(response: ClientHttpResponse): TossPaymentErrorResponse { + private fun parseResponse(response: ClientHttpResponse): TosspayErrorResponse { val body = response.body - return objectMapper.readValue(body, TossPaymentErrorResponse::class.java).also { + return objectMapper.readValue(body, TosspayErrorResponse::class.java).also { body.close() } } diff --git a/src/main/kotlin/roomescape/payment/infrastructure/client/TosspayErrorResponse.kt b/src/main/kotlin/roomescape/payment/infrastructure/client/TosspayErrorResponse.kt index cbfc2d4b..fbb20ccc 100644 --- a/src/main/kotlin/roomescape/payment/infrastructure/client/TosspayErrorResponse.kt +++ b/src/main/kotlin/roomescape/payment/infrastructure/client/TosspayErrorResponse.kt @@ -1,6 +1,6 @@ package roomescape.payment.infrastructure.client -data class TossPaymentErrorResponse( +data class TosspayErrorResponse( val code: String, val message: String ) \ No newline at end of file