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(
|
private class ConfirmClient(
|
||||||
objectMapper: ObjectMapper,
|
private val objectMapper: ObjectMapper,
|
||||||
private val client: RestClient,
|
private val client: RestClient,
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
@ -61,27 +61,33 @@ private class ConfirmClient(
|
|||||||
|
|
||||||
private val errorHandler: TosspayErrorHandler = TosspayErrorHandler(objectMapper)
|
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 {
|
||||||
.uri(CONFIRM_URI)
|
val response = client.post()
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.uri(CONFIRM_URI)
|
||||||
.body(
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
mapOf(
|
.body(
|
||||||
"paymentKey" to paymentKey,
|
mapOf(
|
||||||
"orderId" to orderId,
|
"paymentKey" to paymentKey,
|
||||||
"amount" to amount
|
"orderId" to orderId,
|
||||||
|
"amount" to amount
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
.retrieve()
|
||||||
.retrieve()
|
.onStatus(errorHandler)
|
||||||
.onStatus(errorHandler)
|
.body(String::class.java)
|
||||||
.body(PaymentClientConfirmResponse::class.java)
|
?: run {
|
||||||
?: run {
|
log.error { "[TosspayClient] 응답 바디 변환 실패" }
|
||||||
log.error { "[TosspayConfirmClient.request] 응답 바디 변환 실패" }
|
throw PaymentException(PaymentErrorCode.PAYMENT_UNEXPECTED_ERROR)
|
||||||
throw PaymentException(PaymentErrorCode.PAYMENT_UNEXPECTED_ERROR)
|
}
|
||||||
}
|
|
||||||
|
log.debug { "[TosspayClient.confirm] 응답 수신: json = $response" }
|
||||||
|
|
||||||
|
return objectMapper.readValue(response, PaymentClientConfirmResponse::class.java)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CancelClient(
|
private class CancelClient(
|
||||||
objectMapper: ObjectMapper,
|
private val objectMapper: ObjectMapper,
|
||||||
private val client: RestClient,
|
private val client: RestClient,
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
@ -94,21 +100,26 @@ private class CancelClient(
|
|||||||
paymentKey: String,
|
paymentKey: String,
|
||||||
amount: Int,
|
amount: Int,
|
||||||
cancelReason: String
|
cancelReason: String
|
||||||
): PaymentClientCancelResponse = client.post()
|
): PaymentClientCancelResponse {
|
||||||
.uri(CANCEL_URI, paymentKey)
|
val response = client.post()
|
||||||
.body(
|
.uri(CANCEL_URI, paymentKey)
|
||||||
mapOf(
|
.body(
|
||||||
"cancelReason" to cancelReason,
|
mapOf(
|
||||||
"cancelAmount" to amount,
|
"cancelReason" to cancelReason,
|
||||||
|
"cancelAmount" to amount,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
.retrieve()
|
||||||
.retrieve()
|
.onStatus(errorHandler)
|
||||||
.onStatus(errorHandler)
|
.body(String::class.java)
|
||||||
.body(PaymentClientCancelResponse::class.java)
|
?: run {
|
||||||
?: run {
|
log.error { "[TosspayClient] 응답 바디 변환 실패" }
|
||||||
log.error { "[TosspayClient] 응답 바디 변환 실패" }
|
throw PaymentException(PaymentErrorCode.PAYMENT_UNEXPECTED_ERROR)
|
||||||
throw PaymentException(PaymentErrorCode.PAYMENT_UNEXPECTED_ERROR)
|
}
|
||||||
}
|
|
||||||
|
log.debug { "[TosspayClient.cancel] 응답 수신: json = $response" }
|
||||||
|
return objectMapper.readValue(response, PaymentClientCancelResponse::class.java)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TosspayErrorHandler(
|
private class TosspayErrorHandler(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user