generated from pricelees/issue-pr-template
refactor: 토스페이 응답 JSON 기록을 위한 RestClient 응답 타입 수정
This commit is contained in:
parent
c318f5fc7f
commit
9ce66d8074
@ -52,7 +52,7 @@ class TosspayClient(
|
||||
}
|
||||
|
||||
private class ConfirmClient(
|
||||
objectMapper: ObjectMapper,
|
||||
private val objectMapper: ObjectMapper,
|
||||
private val client: RestClient,
|
||||
) {
|
||||
companion object {
|
||||
@ -61,7 +61,8 @@ private class ConfirmClient(
|
||||
|
||||
private val errorHandler: TosspayErrorHandler = TosspayErrorHandler(objectMapper)
|
||||
|
||||
fun request(paymentKey: String, orderId: String, amount: Int): PaymentClientConfirmResponse = client.post()
|
||||
fun request(paymentKey: String, orderId: String, amount: Int): PaymentClientConfirmResponse {
|
||||
val response = client.post()
|
||||
.uri(CONFIRM_URI)
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.body(
|
||||
@ -73,15 +74,20 @@ private class ConfirmClient(
|
||||
)
|
||||
.retrieve()
|
||||
.onStatus(errorHandler)
|
||||
.body(PaymentClientConfirmResponse::class.java)
|
||||
.body(String::class.java)
|
||||
?: run {
|
||||
log.error { "[TosspayConfirmClient.request] 응답 바디 변환 실패" }
|
||||
log.error { "[TosspayClient] 응답 바디 변환 실패" }
|
||||
throw PaymentException(PaymentErrorCode.PAYMENT_UNEXPECTED_ERROR)
|
||||
}
|
||||
|
||||
log.debug { "[TosspayClient.confirm] 응답 수신: json = $response" }
|
||||
|
||||
return objectMapper.readValue(response, PaymentClientConfirmResponse::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
private class CancelClient(
|
||||
objectMapper: ObjectMapper,
|
||||
private val objectMapper: ObjectMapper,
|
||||
private val client: RestClient,
|
||||
) {
|
||||
companion object {
|
||||
@ -94,7 +100,8 @@ private class CancelClient(
|
||||
paymentKey: String,
|
||||
amount: Int,
|
||||
cancelReason: String
|
||||
): PaymentClientCancelResponse = client.post()
|
||||
): PaymentClientCancelResponse {
|
||||
val response = client.post()
|
||||
.uri(CANCEL_URI, paymentKey)
|
||||
.body(
|
||||
mapOf(
|
||||
@ -104,11 +111,15 @@ private class CancelClient(
|
||||
)
|
||||
.retrieve()
|
||||
.onStatus(errorHandler)
|
||||
.body(PaymentClientCancelResponse::class.java)
|
||||
.body(String::class.java)
|
||||
?: run {
|
||||
log.error { "[TosspayClient] 응답 바디 변환 실패" }
|
||||
throw PaymentException(PaymentErrorCode.PAYMENT_UNEXPECTED_ERROR)
|
||||
}
|
||||
|
||||
log.debug { "[TosspayClient.cancel] 응답 수신: json = $response" }
|
||||
return objectMapper.readValue(response, PaymentClientCancelResponse::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
private class TosspayErrorHandler(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user