GooglePlay Console 后台配置以及支付订单验证流程

               
第一步 获取code(离线code)

组合URL,如下:

https://accounts.google.com/o/oauth2/auth?
scope=https://www.googleapis.com/auth/androidpublisher&
state=123456&
redirect_uri=developers console中设置的重新導向 URI&
response_type=code&
client_id=developers console中的ClientID&
approval_prompt=force
&access_type=offline

访问上面的URL,在弹出确认框中点击确定,跳转到新的网页后,复制浏览器的url

例如:
http://www.thisisgame.com.cn/google.php?state=123456&code=code

code= "code"

取出code:
例如:4/8qzGqVXPAHwD5CspOMoQiS6rPzTzNxJpny11q123OpQ994bs.AtydTx4yH0g234QgrKXntQA11a123x3U85XMkwI

--------------------------------------------------------------------------------------------------------------------

第二步  获取refreshtoken(用于离线刷新)

这里需要执行Post操作:

URL: https://accounts.google.com/o/oauth2/token

Content Type:application/x-www-form-urlencoded

内容:
grant_type=authorization_code
code=上面获取的code
client_id=developers console中的ClientID
client_secret=developers console中的client_secret
redirect_uri=developers console中设置的重新導向 URI

例如:
code=4/hUzPN2YhJUQtdsbbAu2wXtbQ234212334rN1560gSAiWGF7o_4mk8.8mG4R3gvGvIXEnp6123U23434APFm0G8PsbDkwI&client_id=7771985123023459487.apps.googleusercontent.com&client_secret=s9-nF4sgWJ123UM2q412323Sg-hhOXfE&redirect_uri=http://www.thisisgame.com.cn/google.php&grant_type=authorization_code


POST返回数据:
{
  "access_token" : "access_token",
  "token_type" : "Bearer",
  "expires_in" : 3600,
  "refresh_token" : "access_token"
}


查看获取的权限
https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=ya29.yABr0qXqbnZqweqwerSxXu3Hh-7WR2SAtCXQi7kH5Bmu2p8Ny5Dbjw_nzaO7JV6heYKU1iDzAj4TiEmUfKRg

https://developers.google.com/oauthplayground/?code=4/08pnki23e1-n1SBwerweraNmjEWC-KjaaS9kJxCEK2bC3HBUU.4qp2DVaBI50REnp6UAPFm0E8w2DEkwI

https://security.google.com/settings/security/permissions


access Token过期后重新获取Token
https://accounts.google.com/o/oauth2/token

application/x-www-form-urlencoded

grant_type=refresh_token&client_id=777985059487.apps.googleusercontent.com&client_secret=s9-nF4sgWJUM2q4Sg-hhOXfE&refresh_token=1/EjTL8LKlhj4UUtlafg9eWOpklG4XIwSDKUokhG0NUMA

ya29.ygA9icexU3fFqdyvPY5yoh7o_K533VsT9XmdAD4lMbepXFZ9IaoTiKOYxkk2ynGJ5HMfsBlcBVYj-g
----------------------------------------------------------------------------------------

第三步 验证google订单
https://www.googleapis.com/androidpublisher/v1.1/applications/packagename/inapp/商品ID/purchases/支付成功返回的purchase?access_token=access_Token

https://www.googleapis.com/androidpublisher/v1.1/applications/tw.com.joybomb.tan/inapp/tan_diamond_60/purchases/hceipdfgccjjjajbjmfanfbb.AO-J1OzYNGV09inOGzUU4gUW1QUcVAgzF2R1ETclYaC6uwSbEi90Bh4aqLCbDpUoYwu879U-g3RFeRvI7Ln5DUriT-A8M-cV6-Dp8INB39fvjbkht-8_dUbYQy8sdvm4H4PrVXJB1ZN2?access_token=ya29.ygA9icexU3fFqdyvPY5yoh7o_K533VsT9XmdAD4lMbepXFZ9IaoTiKOYxkk2ynGJ5HMfsBlcBVYj-g

验证返回:https://developers.google.com/android-publisher/api-ref/purchases/products#resource

总结:
1、获取AccessToken
https://developers.google.com/android-publisher/authorization

2、请求订单状态
https://developers.google.com/android-publisher/api-ref/purchases/products/get

3、订单状态返回
https://developers.google.com/android-publisher/api-ref/purchases/products#resource           

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

猜你喜欢

转载自blog.csdn.net/qq_43667944/article/details/86644820