generated from pricelees/issue-pr-template
chore: Tosspayment -> Tosspay 네이밍 통일
This commit is contained in:
parent
a4f384a242
commit
752943a9f7
@ -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,
|
||||
|
||||
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package roomescape.payment.infrastructure.client
|
||||
|
||||
data class TossPaymentErrorResponse(
|
||||
data class TosspayErrorResponse(
|
||||
val code: String,
|
||||
val message: String
|
||||
)
|
||||
Loading…
x
Reference in New Issue
Block a user