在Backend Node.js上验证Google Play中的应用内购买

时间:2015-04-15 07:21:14

标签: node.js in-app-purchase google-play-services

我正在开发一款具有某种应用内购买功能的移动应用。

现在在后端/服务器端我想验证来自谷歌的购买信息。节点中有很少的模块用于验证,但它们只是验证数据是否正确,但不是联系谷歌相同。 任何人都可以给予任何相同的建议.. 应用内购买数据就像是。

{
   "orderId":"12999763169054705758.1364365967744519",
   "packageName":"my package name",
   "productId":"77",
   "purchaseTime":1366217534000,
   "purchaseState":0,
   "purchaseToken":"utfwimslnrrwvglktizikdcd.AOJ1OwZ4l5oXz_3d2SAWAAUgFE3QErKoyIX8WuSEnBW26ntsyDmlLgoUd5lshqIY2p2LnlV4tpH4NITB4mJMX98sCtZizH7wGf6Izw3tfW_GflJDKFyb-g"
}

1 个答案:

答案 0 :(得分:1)

您是否尝试了同级的iab_verifier模块

在此Google Play中,公钥需要对应用结算进行身份验证

var IABVerifier = require('iab_verifier'),

var googleplay_public_key = "-- YOUR PUBLIC KEY --";
var googleplayVerifier = new IABVerifier(googleplay_public_key);

var receiptData = receiptDataFromClient;
var receiptSignature = signatureDataFromClient;

var isValid = googleplayVerifier.verifyReceipt(receiptData,receiptSignature);

if (result) {
    // Receipt is valid. Grab a beer celebrate!
} else {
    // Receipt is NOT valid... 
} 

感谢