generated from pricelees/issue-pr-template
[#35] 결제 스키마 재정의 & 예약 조회 페이지 개선 #36
@ -26,15 +26,19 @@ class TosspaymentClientV2(
|
|||||||
private val cancelClient = CancelClient(objectMapper, tossPaymentClientBuilder.build())
|
private val cancelClient = CancelClient(objectMapper, tossPaymentClientBuilder.build())
|
||||||
|
|
||||||
fun confirm(request: PaymentConfirmRequest): PaymentConfirmResponse {
|
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 {
|
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)
|
.body(request)
|
||||||
.retrieve()
|
.retrieve()
|
||||||
.onStatus(errorHandler)
|
.onStatus(errorHandler)
|
||||||
.body(PaymentConfirmResponse::class.java)
|
.body(PaymentConfirmResponse::class.java) ?: run {
|
||||||
?: run {
|
|
||||||
log.error { "[TossPaymentConfirmClient.request] 응답 바디 변환 실패" }
|
log.error { "[TossPaymentConfirmClient.request] 응답 바디 변환 실패" }
|
||||||
throw PaymentException(PaymentErrorCode.PAYMENT_UNEXPECTED_ERROR)
|
throw PaymentException(PaymentErrorCode.PAYMENT_UNEXPECTED_ERROR)
|
||||||
}
|
}
|
||||||
@ -103,7 +106,7 @@ private class TosspayErrorHandler(
|
|||||||
response: ClientHttpResponse
|
response: ClientHttpResponse
|
||||||
): Nothing {
|
): Nothing {
|
||||||
val requestType: String = paymentRequestType(url)
|
val requestType: String = paymentRequestType(url)
|
||||||
log.warn { "[TossPaymentClient] $requestType 요청 실패: response: ${toErrorResponse(response)}" }
|
log.warn { "[TossPaymentClient] $requestType 요청 실패: response: ${parseResponse(response)}" }
|
||||||
|
|
||||||
throw PaymentException(paymentErrorCode(response.statusCode))
|
throw PaymentException(paymentErrorCode(response.statusCode))
|
||||||
}
|
}
|
||||||
@ -123,7 +126,7 @@ private class TosspayErrorHandler(
|
|||||||
PaymentErrorCode.PAYMENT_PROVIDER_ERROR
|
PaymentErrorCode.PAYMENT_PROVIDER_ERROR
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun toErrorResponse(response: ClientHttpResponse): TossPaymentErrorResponse {
|
private fun parseResponse(response: ClientHttpResponse): TossPaymentErrorResponse {
|
||||||
val body = response.body
|
val body = response.body
|
||||||
|
|
||||||
return objectMapper.readValue(body, TossPaymentErrorResponse::class.java).also {
|
return objectMapper.readValue(body, TossPaymentErrorResponse::class.java).also {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user