제이킹
제이킹
웹훅 응답 객체 관련 문의
안녕하세요. 웹훅 응답에 관련하여 문의드립니다. 오늘 AWS ECS Log를 확인하던 도중 다음과 같은 에러가 발생한 것을 확인하였습니다. 우리나라 시간 기준, 2023-01-09T09:46:43.234+09:00 발생.
org.springframework.web.server.ServerWebInputException: 400 BAD_REQUEST "Failed to read HTTP message"; nested exception is org.springframework.core.codec.DecodingException: JSON decoding error
JSON decoding error: Instantiation of [...Payment] value failed for JSON property method due to missing (therefore NULL) value for creator parameter method which is a non-nullable type
...
TossWebhookPayload["data"]-> ... Payment["method"]
...
error: 400 BAD_REQUEST "P1:사용가능한 포인트가 부족합니다"
...
org.springframework.web.server.ServerWebInputException: 400 BAD_REQUEST "Failed to read HTTP message"; nested exception is org.springframework.core.codec.DecodingException: JSON decoding error
JSON decoding error: Instantiation of [...Payment] value failed for JSON property method due to missing (therefore NULL) value for creator parameter method which is a non-nullable type
...
TossWebhookPayload["data"]-> ... Payment["method"]
...
error: 400 BAD_REQUEST "P1:사용가능한 포인트가 부족합니다"
...
현재 저희는 상점관리자 - 주문내역 - 취소에 대한 웹훅, PAYMENT_STATUS_CHANGE 만 사용합니다. 토스페이먼츠 공식문서에 따르면 Paymentmethod field 는 non-nullable type 으로 응답 시 반드시 내려주는 것으로 아래와 같이 확인하였습니다.
method string
결제할 때 사용한 결제 수단입니다. 카드, 가상계좌, 간편결제, 휴대폰, 계좌이체, 상품권(문화상품권, 도서문화상품권, 게임문화상품권) 중 하나입니다.
method string
결제할 때 사용한 결제 수단입니다. 카드, 가상계좌, 간편결제, 휴대폰, 계좌이체, 상품권(문화상품권, 도서문화상품권, 게임문화상품권) 중 하나입니다.
따라서 PAYMENT_STATUS_CHANGE 웹훅이벤트에 대한 Paymentmethod field 가 nullable 하게 응답될 수 있는지의 케이스에 대하여 문의드립니다.
12 replies
토스페이먼츠 결제 취소 웹훅 관련 문의드립니다.
안녕하세요, 결제 취소 Webhook 관련 문의드립니다. 먼저 테스트 환경은 다음과 같습니다. 1. 테스트 Webhook 2. 라이브 Webhook 저희가 사용하고 있는 토스페이먼츠 Webhook Event 는 다음과 같습니다. - PAYMENT_STATUS_CHANGED 토스페이먼츠 공식 문서에 따르면, PAYMENT_STATUS_CHANGED Event 의 응답 객체는 아래와 같습니다. https://docs.tosspayments.com/reference#payment-%EA%B0%9D%EC%B2%B4 문제는 저희 측에서 "토스페이먼츠 - 상점 - 결제 내역 - 결제취소" 를 진행하였을 때 전송된 Webhook 을 처리하는 과정에서 다음과 같은 에러가 발생합니다.
org.springframework.web.server.ServerWebInputException: 400 BAD_REQUEST “Failed to read HTTP message”; nested exception is org.springframework.core.codec.DecodingException: JSON decoding error: Instantiation of [simple type, class ....] value failed for JSON property version due to missing (therefore NULL) value for creator parameter version which is a non-nullable type; nested exception is com.fasterxml.jackson.module.kotlin.MissingKotlinParameterException: Instantiation of [simple type, class ....] value failed for JSON property version due to missing (therefore NULL) value for creator parameter version which is a non-nullable type
org.springframework.web.server.ServerWebInputException: 400 BAD_REQUEST “Failed to read HTTP message”; nested exception is org.springframework.core.codec.DecodingException: JSON decoding error: Instantiation of [simple type, class ....] value failed for JSON property version due to missing (therefore NULL) value for creator parameter version which is a non-nullable type; nested exception is com.fasterxml.jackson.module.kotlin.MissingKotlinParameterException: Instantiation of [simple type, class ....] value failed for JSON property version due to missing (therefore NULL) value for creator parameter version which is a non-nullable type
at [Source: (io.netty.buffer.ByteBufInputStream); line: 1, column: 1624] (through reference chain: ....TossWebhookPayload[“data”]->....[“version”])
at [Source: (io.netty.buffer.ByteBufInputStream); line: 1, column: 1624] (through reference chain: ....TossWebhookPayload[“data”]->....[“version”])
즉, 결제취소 시 PAYMENT_STATUS_CHANGED Event 를 통해 받은 토스페이먼츠 Json 에 version field 정보가 없어 Deserialize 에러가 발생하는데, 공식 문서에는 version field 가 Notnull 로 명시 되어있습니다.
{
"data": {
"mId": "tosspayments",
"version": "2022-11-16", // Not null
{
"data": {
"mId": "tosspayments",
"version": "2022-11-16", // Not null
테스트 환경에서의 Webhook 테스트 시에는 version field 가 담겨 정상적으로 응답하지만, 라이브 환경에서의 Webhook 테스트 시에는 version field 가 담겨오지 않아 Decode 에러가 발생합니다. 정리하자면, Webhook 의 PAYMENT_STATUS_CHANGED Event 를 통한 응답객체의 데이터 중 version field 가 문서에는 Notnull 이지만 Null로 들어와 Decode 에러가 발생합니다. 또한 동일한 조건에서, 테스트 Webhook 환경과 라이브 Webhook 환경의 결과가 다릅니다. version field 의 index 가 우선이므로 에러는 해당 필드에서 발생하였지만 다음 field 에서의 동일한 문제가 발생할 가능성이 있습니다. 라이브 Webhook 환경에서, 공식문서에 기반한 응답값 체크확인 부탁드립니다.
16 replies