请支付谷歌支付服务器上检查
2015-01-28 17:52
85 查看
http://translate.google.com.tw/translate?hl=zh-CN&sl=ru&u=http://habrahabr.ru/post/240447/&prev=search
我想分享与支付从谷歌播放服务器应用程序检查连接的体验。
所以. 我们有一个应用程序准备出版( 链接 )。 同一组的付款项目(的链路 ),并与该应用程序相关联。
接下来,逐点。
1.有必要去标签凭证;
2.创建客户端ID作为网络应用程序,并指定redirect_uri到我们的服务器(例如, server.ru和回调server.ru/callback );
3.创建密钥类型ServerKey(可以是空的和数据)。
在服务器上,做传入变量处理程序代码server.ru/callback 。
它会作为一个GET请求。
下面是处理语言的例子Python的存储数据的萝卜 。
接下来,你需要填写页面«同意屏»,以及激活API«谷歌的Android游戏开发者API»。
现在,您需要在我们的服务器上的授权服务。
可以肯定,这必须从该帐户,这是与支付项目创建完成。
那么这个帐户下去的链接 ,取代....... 我们的ClientID。
此链接只发送给我们的回调变量的代码。
一旦您的帐户能够与支付操作。
收到付款Peredaёm服务器数据由客户端从谷歌,并与他的手检查。
如果从客户端数据与谷歌的数据一致拍摄,你可以放心地收取用户的虚拟货币。
我想分享与支付从谷歌播放服务器应用程序检查连接的体验。
所以. 我们有一个应用程序准备出版( 链接 )。 同一组的付款项目(的链路 ),并与该应用程序相关联。
接下来,逐点。
1.有必要去标签凭证;
2.创建客户端ID作为网络应用程序,并指定redirect_uri到我们的服务器(例如, server.ru和回调server.ru/callback );
3.创建密钥类型ServerKey(可以是空的和数据)。
在服务器上,做传入变量处理程序代码server.ru/callback 。
它会作为一个GET请求。
下面是处理语言的例子Python的存储数据的萝卜 。
import requests, redis Redis = redis.Redis() data = requests.post('https://accounts.google.com/o/oauth2/token',{'code':code,'grant_type':'authorization_code','client_id':client_id,'client_secret':client_secret,'redirect_uri':'http://server.ru/callback/'}) jdata = data.json() if 'access_token' in jdata and 'token_type' in jdata and 'expires_in' in jdata: Redis.setex('GooglePayAccess',jdata['access_token'],jdata['expires_in']) Redis.setex('GooglePayType',jdata['token_type'],jdata['expires_in']) if "refresh_token" in jdata: Redis.set('GooglePayRefresh',jdata['refresh_token'])[/code]
接下来,你需要填写页面«同意屏»,以及激活API«谷歌的Android游戏开发者API»。
现在,您需要在我们的服务器上的授权服务。
可以肯定,这必须从该帐户,这是与支付项目创建完成。
那么这个帐户下去的链接 ,取代....... 我们的ClientID。
[code]https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/androidpublisher&response_type=code&access_type=offline&redirect_uri=http://server.ru/callback/&client_id=……………………………………[/code]
此链接只发送给我们的回调变量的代码。
一旦您的帐户能够与支付操作。
收到付款Peredaёm服务器数据由客户端从谷歌,并与他的手检查。
[code]import requests, redis Redis = redis.Redis() access_token = Redis.get('GooglePayAccess') token_type = Redis.get('GooglePayType') if not access_token or not token_type: refresh_token = Redis.get('GooglePayRefresh') data = requests.post('https://accounts.google.com/o/oauth2/token',{'grant_type':'refresh_token','client_id':client_id,'client_secret':client_secret,'refresh_token':refresh_token}) jdata = data.json() if 'access_token' in jdata and 'token_type' in jdata and 'expires_in' in jdata: access_token = jdata['access_token'] token_type = jdata['token_type'] Redis.setex('GooglePayAccess',access_token,jdata['expires_in']) Redis.set('GooglePayType',token_type,jdata['expires_in']) url = 'https://www.googleapis.com/androidpublisher/v2/applications/%s/purchases/products/%s/tokens/%s?key=%s' % (packageName,productId,purchaseToken,api_key) response = requests.get(url,headers={"Authorization":"%s %s" % (token_type,access_token)}) jdata2 = response.json()[/code]
如果从客户端数据与谷歌的数据一致拍摄,你可以放心地收取用户的虚拟货币。
相关文章推荐
- 移动支付宝支付, 安卓 + nodejs 服务器
- java检查服务器的连通两种方法代码分享
- 网狐登录提示,服务器连接失败,请检查网络配置以及网络连接状况
- c#如何检查局域网内服务器是否连通
- 动软出现“添加服务器配置失败,请检查是否有写入权限或文件是否存在“错误
- 谷歌支付验证2
- 服务器日常检查范围及方法
- 检查本地服务器是否配置成功
- Radware WSD的服务器健康检查
- 检查apache服务器是否正在运行的脚本
- nginx后端节点服务器健康检查二
- Unity内IAP支付二次验证/服务器验证————最白话,手把手教你做系列。
- 批量检查服务器联通性(ping)
- 健康检查功能不会更新后端服务器
- iOS支付(含服务器验证)
- 服务器安全检查防护(不完全篇)
- 谷歌高管笑谈往事:曾“误伤”eBay服务器
- 打开FTP服务器上的文件夹时发生错误,请检查是否有权限访问该文件夹