Google Play Developer API를 사용하여 안드로이드의 in-app billing 영수증 확인 (메모)
4186 단어 AndroidIn-appBilling
Google Play Developer API를 사용하여 영수증 확인
※ 완전한 개인 메모여서 내용이 새롭지 않고, 원래 쓸 때 가장 좋지 않을 수도 있습니다.
전제 조건
· 인앱빌링을 통해 소비형 물품 판매 시 영수증 정보가 정확한지 확인
• 영수증 정보 취득 등이 이미 이루어졌다
차리다
OAuth 인증
브라우저를 통해 다음 URL에 액세스
https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/androidpublisher&response_type=code&access_type=offline&redirect_uri=http://localhost&client_id=<準備.4で確認したクライアントID>
Google 계정 링크 화면 허용http://localhost/?code=4/AACyzBvuCgBZQKv8VKPvCQl5Szt6U47GClAPLk0qTuItTUmUoFKJWqUfSyJN2bTCqLDXXXXXXXXXXXXXXXXXXXX#
URL에 연결되어 있으므로 code=의 섹션
액세스 토큰 획득
POST 요청을 위해 Curl로 실행
$ curl -v -X POST 'https://accounts.google.com/o/oauth2/token' -d 'grant_type=authorization_code&code=<上記OAuth認証で取得したCode#まで>&client_id=<準備.4で確認したクライアントID>&client_secret=準備.4で確認したクライアントシークレット>&redirect_uri=http://localhost'
상술한 결과를 되돌려주기 때문에accesstoken/refresh_Token 확인
영수증 검증
드디어 주제
영수증 정보에서
・package Name
・ProductId
・purchaseToken
미리 확인한다
우선 수동 검증...
$ curl -v 'https://www.googleapis.com/androidpublisher/v3/applications/<packageName>/purchases/products/<productId>/tokens/<purchaseToken>?access_token=<アクセストークン取得で取得したaccess_token>'
위와 같은 결과가 나오면 OK입니다.
결과 상세 정보https://developers.google.com/android-publisher/api-ref/purchases/products#resource
요컨대
consumptionState:1
개발자 Paylload: 결제 시 보낸 유효 하중과 일치하는지 여부
purchaseState:0
주변 상황을 확인하고 검증하는 게 좋을 것 같아요.
여기까지 확인한 후 동일한 처리를 실시해야 한다
문제는access입니다.Token은 수령 시작 1시간 이내에 만료됩니다.
access_Token 업데이트
$ curl -v -X POST 'https://accounts.google.com/o/oauth2/token' -d 'grant_type=refresh_token&client_id=<クライアントID>&client_secret=<クライアントシークレット>&refresh_token=<アクセストークン取得時に確認したrefresh_token>'
새로운 access토큰을 획득할 수 있습니다.
프로세스 구현
상술한 내용에 근거하여
참고 자료
https://groups.google.com/forum/#!topic/android-group-japan/jaaIGAl2lPE
http://d.hatena.ne.jp/fkm/20130504
https://developers.google.com/android-publisher/api-ref/purchases/products
Reference
이 문제에 관하여(Google Play Developer API를 사용하여 안드로이드의 in-app billing 영수증 확인 (메모)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/nakayama_cw/items/395aa655c9f311d2efac텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)