略微加速

略速 - 互联网笔记

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

2019-08-01 leiting (6069阅读)

标签 开发编程

第一步 获取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

==========================================================

Purchases.products


For a list of methods for this resource, see the end of this page.

Resource representations

A ProductPurchase resource indicates the status of a user's inapp product purchase.

{
  "kind": "androidpublisher#productPurchase",
  "purchaseTimeMillis":,
  "purchaseState":,
  "consumptionState":,
  "developerPayload":,
  "orderId":,
  "purchaseType":,
  "acknowledgementState":
}
Property nameValueDescriptionNotes
acknowledgementStateintegerThe acknowledgement state of the inapp product. Possible values are:
  1. Yet to be acknowledged

  2. Acknowledged


consumptionStateintegerThe consumption state of the inapp product. Possible values are:
  1. Yet to be consumed

  2. Consumed


developerPayloadstringA developer-specified string that contains supplemental information about an order.
kindstringThis kind represents an inappPurchase object in the androidpublisher service.
orderIdstringThe order id associated with the purchase of the inapp product.
purchaseStateintegerThe purchase state of the order. Possible values are:
  1. Purchased

  2. Canceled

  3. Pending


purchaseTimeMillislongThe time the product was purchased, in milliseconds since the epoch (Jan 1, 1970).
purchaseTypeintegerThe type of purchase of the inapp product. This field is only set if this purchase was not made using the standard in-app billing flow. Possible values are:
  1. Test (i.e. purchased from a license testing account)

  2. Promo (i.e. purchased using a promo code)

  3. Rewarded (i.e. from watching a video ad instead of paying)


Methods

  • acknowledge

  • Acknowledges a purchase of an inapp item.

  • get

  • Checks the purchase and consumption status of an inapp item.


北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3