์ค๋ฅ์ ์์ธ๋ค
- (๊ตฌ) ์นด์นด์คํ์ด API ์์ 2024์ ์๋ก ๋ฐ๋๋ฉด์ ํ์์์ด์ง ํ๋๊ฐ ๋๋ฌธ์
- Jackson ๋ชจ๋
- url ์ค์
- key๊ฐ์ dev์ฉ์ผ๋ก ์์จ์
- ํ๋ ๋ถ์ผ์น
- ์ธ์ฆ ํค ๋ณ๊ฒฝ๋จ
- (๊ตฌ) headers.set("Authorization", "KakaoAK " + kakaoPayConfig.getSecretKeyDev());
- (์ ) headers.set("Authorization", "SECRET_KEY " + kakaoPayConfig.getSecretKeyDev());
์นด์นด์ค๊ฐ ์ ๊ณตํ๋ ๊ฒฐ์ ์ค๋ฅ์ฝ๋ ์ ๋ฆฌ ์์ ํ์ผ
๋ด๊ฐ ๊ฒช์ ์ค๋ฅ ๋ฉ์ธ์ง ์ ๋ฆฌ
์ค๋ฅ ๋ฉ์ธ์ง | Create breakpoint | ์์ธ (์ถ์ธก) | ํด๊ฒฐ๋ฐฉ๋ฒ |
org.springframework.web.client.HttpClientErrorException$BadRequest | 400 Bad Request: "{"error_code":-400,"error_message":"์๋ชป๋ ์์ฒญ"}" | url์์ String requestUrl = "https://open-api.kakaopay.com/online/v1/payment/ready"; key ์์ "SECRET_KEY " + kakaoPayConfig.getSecretKeyDev() |
|
org.springframework.web.client.HttpClientErrorException$NotFound | 404 Not Found: "{"timestamp":"2024-03-27T14:49:47.670+00:00","status":404,"error":"Not Found","path":"/"}" | url์์ String requestUrl = "https://open-api.kakaopay.com/online/v1/payment/ready"; key ์์ "SECRET_KEY " + kakaoPayConfig.getSecretKeyDev() |
|
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException | : Unrecognized field "tms_result" (class com.labmate.riddlebox.dto.kakaopay.PaymentResponseDTO), not marked as ignorable (7 known properties: "android_app_scheme", "ios_app_scheme", "next_redirect_mobile_url", "next_redirect_app_url", "tid", "next_redirect_pc_url", "created_at"]) | ๋ฌธ์์ ์๋ ํ๋ ๋๋ฌธ ์นด์นด์ค ๋ฌธ์์ผํฐ ๊ธ๋ก ์ถ์ธกํ์๋ฉด ์๋ก์ด API๋ก ๋ฐ๊พธ๋ฉด์ ํ์์์ด์ง ๊ธฐ์กด API ํ๋์ธ๋ฏ |
PaymentResponseDTO์ private boolean tms_result; ์ถ๊ฐ ๋งค์นญ ์๋๋ ํ๋ ๋ฌด์ํ๊ธฐ ์ ๋ํ ์ด์ ์ถ๊ฐ @JsonIgnoreProperties(ignoreUnknown = true) |
org.springframework.web.client.HttpClientErrorException$BadRequest | 400 Bad Request: "{"extras":null,"error_message":"totalAmount, taxFreeAmount, vatAmount, greenDeposit is invalid!","error_code":-722}" | ์นด์นด์ค ์๋ฌ์ฝ๋ ์ค๋ช ์ผ๋ก๋ ๊ธ์ก ์ ๋ณด๊ฐ ์๋ชป๋ ๊ฒฝ์ฐ | Amount ํด๋์ค์ ํ๋ ์ถ๊ฐ private Integer taxFreeAmount; // ๋น๊ณผ์ธ ๊ธ์ก private Integer vatAmount; // ๋ถ๊ฐ์ธ ๊ธ์ก |
com.fasterxml.jackson.databind.exc.InvalidDefinitionException | Java 8 date/time type `java.time.LocalDateTime` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling | ์์กด์ฑ ์ถ๊ฐ // Java 8 ๋ ์ง/์๊ฐ ์ง์์ ์ํ Jackson ๋ชจ๋ ๋ฑ๋ก implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.0' // Java 8 ๋ ์ง/์๊ฐ ๋ชจ๋ ๋ฑ๋ก // ObjectMapper ์ธ์คํด์ค ์์ฑ ObjectMapper objectMapper = new ObjectMapper(); // Java 8 ๋ ์ง/์๊ฐ ๋ชจ๋ ๋ฑ๋ก objectMapper.registerModule(new JavaTimeModule()); |
|
org.springframework.web.client.HttpClientErrorException$NotFound | 404 Not Found: "{"error_code":-404,"error_message":"๋ฆฌ์์ค ๋ฏธ์กด์ฌ"}" | URL ์์ online์ด ๋น ์ ธ์์์ https://open-api.kakaopay.com/online/v1/payment/approve |
|
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: | Unrecognized field "sid" | ๊ฒฐ์ ์นดํก์ ์์ง๋ง ์ค๋ฅ๋ฉ์ธ์ง ์ถ๋ ฅ๋จ ์ ์์ํ ํ๋ ์์ ์๋ ์๊ณ , jackson ๋ ์ง์๊ฐ ์ฝ๋ ์ถ๊ฐ ์ํด์ ๊ทธ๋ฐ๋ฏ |
// ํ๋ ์ถ๊ฐ KakaoPaymentApproveResponseDTO
์ private String sid; ์ ๋ํ ์ด์ ์ถ๊ฐ @JsonIgnoreProperties(ignoreUnknown = true) public class KakaoPaymentApproveResponseDTO
์์ฑ์์์ ๋ชจ๋ ํ๋ฒ์ ๋ฑ๋กํด์ Java 8 ๋ ์ง/์๊ฐ API ์ง์ ํ์ฑํ this.objectMapper = new ObjectMapper(); this. objectMapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE); |
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: | Unrecognized field "tax_free" | ์๋ ํ๋ ์ธ์ ๋ชปํจ Amount ํด๋์ค์์ tax_free ํ๋๋ฅผ ์ธ์ํ์ง ๋ชปํ๋ ๋ฌธ์ ํด๋์ค ๋ณ์๋ช ์ ์นด๋ฉ์ผ์ด์ค๋ก ์์ (์ค์๋ก db์ฒ๋ผ ์ ์ธํด๋ฒ๋ฆผ) |
[1] ์ ๋ํ
์ด์
๋ถ์ด๊ฑฐ๋ @JsonProperty("tax_free") private Integer taxFree; [2]ObjectMapper ์ค์ ์ ์ฒด๋ณ๊ฒฝ this.objectMapper.setPropertyNamingStrategy( PropertyNamingStrategies.SNAKE_CASE); |