|
@@ -216,6 +216,77 @@ var pay_success = function(args,res){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+let googleplay = function(args, res){
|
|
|
+ if (args==null){
|
|
|
+ console.log("[GooglePlay] 无效的充值请求!");
|
|
|
+ try{res.send("error,1");}
|
|
|
+ catch(e){}
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ let obj = null
|
|
|
+ try {
|
|
|
+ obj = qs.parse(args);
|
|
|
+ } catch(e){
|
|
|
+ console.log("[GooglePlay] 无效的充值请求!");
|
|
|
+ try{res.send("error,1");}
|
|
|
+ catch(e){}
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ const data = JSON.stringify({
|
|
|
+ grant_type : "refresh_token",
|
|
|
+ refresh_token : "1//0e3sYXF6c7hfMCgYIARAAGA4SNwF-L9IrVKAk6l2BMnTqOTqTxZ6_6Sy7y5LHfKUYqXQFvHuOu8WUuTq31l1kGTeLvylvo-hg8pc",
|
|
|
+ client_id : "1053688457546-djajb15ii7v0q6pjsh7361fpsh97353g.apps.googleusercontent.com",
|
|
|
+ client_secret : "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"
|
|
|
+ })
|
|
|
+
|
|
|
+ console.log(data)
|
|
|
+
|
|
|
+ let options = {
|
|
|
+ hostname: 'accounts.google.com',
|
|
|
+ port: 443,
|
|
|
+ path: '/o/oauth2/token',
|
|
|
+ method: 'POST',
|
|
|
+ rejectUnauthorized: false,
|
|
|
+ headers: {
|
|
|
+ 'Content-Type': 'Application/json',
|
|
|
+ 'Content-Length':data.length
|
|
|
+ },
|
|
|
+ };
|
|
|
+
|
|
|
+ let req = https.request(options, function (res){
|
|
|
+ let responseData = '';
|
|
|
+ res.on('data', (chunk) => {
|
|
|
+ responseData += chunk;
|
|
|
+ });
|
|
|
+
|
|
|
+ res.on('end', () => {
|
|
|
+ console.log('Response:', responseData);
|
|
|
+ // 在这里可以处理响应数据
|
|
|
+ });
|
|
|
+ }).on('error', (err) => {
|
|
|
+ if (err.code === 'ECONNRESET') {
|
|
|
+ console.error('连接被重置:', err.message);
|
|
|
+ } else {
|
|
|
+ console.error('网络请求时发生错误:', err.message);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ req.write(data);
|
|
|
+ req.end();
|
|
|
+
|
|
|
+ let orderid = obj.orderid; //订单号
|
|
|
+ let serverid = obj.serverid;//服务器id
|
|
|
+ let userid = obj.userid; //玩家的渠道帐号
|
|
|
+ let uid = obj.uid; //玩家游戏uid
|
|
|
+ let platformid = obj.platformid;//googleplay
|
|
|
+ let gp_appid = obj.channel; //渠道
|
|
|
+ let ti = new Date().Format("yyyy-MM-dd hh:mm:ss");
|
|
|
+ let payment_type = "GooglePlay" + gp_appid;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
router.post('/googleplay', function(req, res) {
|
|
|
console.log("谷歌,post ,host:%s, ip:%s,date:%s",req.hostname,req.ip,new Date());
|
|
|
var data = "";
|
|
@@ -223,7 +294,7 @@ router.post('/googleplay', function(req, res) {
|
|
|
data += chunk;
|
|
|
})
|
|
|
req.on("end",function(){
|
|
|
- pay_success(data,res);
|
|
|
+ googleplay(data,res);
|
|
|
})
|
|
|
req.on("error",function(err){
|
|
|
res.send('erron,1');
|