유니티

[유니티] IAP 검증 서버 이슈

VicGameStudio_Choi 2022. 12. 16. 18:14

지난 번 IAP 검증 서버 구현에 이은 이슈를 정리해보려고 한다.

 

https://victorygamestudio.tistory.com/20

 

[유니티] 구글 IAP 영수증 검증 서버 구현 feat. firebase 호스팅

IAP 로 구현까지 다 진행하고.. 영수증 검증을 하기 위해 이것저것 찾아보던 중.. 제대로 된 글이 있어서 참고해서 진행하였다. 영수증 검증을 하기 위한 방법은 여러 가지가 있지만, 이 글에서는

victorygamestudio.tistory.com

 

구현을 다 따라했더니... 몇 가지 에러가 발생했다..

 

1. 링크의 주소가 바꼈다.

//let getUrl = `https://www.googleapis.com/androidpublisher/v2/applications/${packageName}/purchases/products/${productId}/tokens/${token}?access_token=${tokenStorage.access_token}`;
let getUrl = `https://androidpublisher.googleapis.com/androidpublisher/v3/applications/${packageName}/purchases/products/${productId}/tokens/${token}?access_token=${tokenStorage.access_token}`;

 

원래는 위의 주석의 url 로 구글 검증을 보냈는데.. 현재는 아래 URL 로 바뀌었음.

 

2. Google Play Android Developer API

Google Play Android Developer API 는 검증하면서 발생한 에러 메시지가 알려준 것이다.

 

해당 주소로 api 를 보내게 되면, 다음과 같은 메세지를 받게됨. ( 물론, 올바른 데이터를 넣어주었다는 가정하에 )

 

   "message": "Google Play Android Developer API has not been used in project 44 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/androidpublisher.googleapis.com/overview?project=각자클라우드프로젝트번호 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.","

url 로 들어가서 Google Play Android Developer API 를 추가하면 된다.

 

하지만.. 여기까지 한다고 되는 것이 아니다.. 하하하하..

 

"message": "The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console."

위와 같은 메세지를 볼 수 있다.

이건 구글 클라우드 콘솔과 구글 플레이 콘솔하고 연동이 되지 않아서 그렇다.

 

https://play.google.com/console/about/

 

Google Play Console | Google Play Console

앱 및 게임이 성장할 수 있도록 사용자에게 도달하고 사용자 참여를 유도하는 데 도움이 될 도구, 프로그램, 통계를 이용하세요.

play.google.com

 

구글 플레이 콘솔 접속

 

API 엑세스에 접근해서 기존에 작업하고 있는 구글 클라우드 프로젝트에 연결한다.

새로 생성하거나 기존 프로젝트와 연결한다.

 

 

잠시 뒤에... 다시 제품 구매 시도 시.. 드디어.. 검증 결과를 받았다 하..

 

3. 기타 에러 사항

3-1 Refresh Token 발급

 

refresh_token 을 얻지 못해서... 만료된 access_token 을 다시 못받은 상황..

refresh_token 의 경우, auth 최초 연결 시 한 번만 받을 수 있다. 

나는.. 받은 줄도 모르고 왜 refresh_token 이 없는거지만 외치고 있었다.....

아래에서 계정에 액세스 할 수 있는 앱을 삭제하고 다시 auth 토큰 발급 시, refresh token 까지 같이 받을 수 있다.

저장해서 사용하면 된다 ㅎㅎ

 

내 계정에 액세스할 수 있는 타사 사이트 및 앱 : 네이버 블로그 (naver.com)

 

내 계정에 액세스할 수 있는 타사 사이트 및 앱

내 계정에 액세스할 수 있는 타사 사이트 및 앱사용자가 안전하게 데이터를 공유할 수 있도록 Google은 사...

blog.naver.com

 

3-2 액세스 토큰 삭제하다가 Google Cloud CLI 를 삭제했을 때..

 

firebase deploy 진행하려니.. 계속 failed to get firebase project 가 발생함.

이 경우에 firebase init 을 하지 말고 침착하게 firebase logout > firebase login 을 하자. 그러면 다시 Google Cloud CLI 에 연결됨 ㅋ

 

https://cishome.tistory.com/219

 

오랜만에 firebase hosting 에 deploy 시 failed to get firebase project 에러가 나타나는 경우

한참동안 사용하지 않다가 오랜만에 firebase hosting에 deploy 할 일이 생겨서 시도해보았는데 몇 번을 시도해도 계속 같은 에러가 나타났습니다. 뭔가 이상이 생긴것 같아서 정보를 찾아보니 생각보

cishome.tistory.com