【发布时间】:2018-09-07 01:24:33
【问题描述】:
所以事情就是这样 - 我有一个用于我的 Android 应用程序的 node.js 后端服务器。我正在使用 Google Play 计费库,并按照 google Docs 的建议使用后端来验证购买。
现在,关于此错误的所有其他答案似乎都指向一个一致的问题。
我的后端有时会进行验证,但有时会将此作为错误返回,这表明事实上,我的服务帐户已关联(如我的控制台中所示)。
我尝试了两个不同的 3rd 方库,但我遇到了同样的问题。有时一个会回复验证成功,而另一个会说我的帐户未关联。有时它们都是消极的,有时都是积极的。
似乎不一致。
var platform = 'google';
var payment = {
receipt: purchaseToken, // always required ... this is google play purchaseToken
productId: subID, // my subscription sku id
packageName: 'com.xxxxxx', // my package name
keyObject: key, // my JSON file
subscription: true, // optional, if google play subscription
};
var promise2 = iap.verifyPayment(platform, payment, function (error, response) {
/* your code */
if (error) {
console.log('error with iap, ' , error);
return true;
} else {
console.log('success with iap, response is: ', response);
return true;
}
});
我也尝试了不同的库,得到了相同的结果:
var receipt = {
packageName: "com.xxxx",
productId: subID, // sku subscription id
purchaseToken: purchaseToken // my purchase token
};
var promise = verifier.verifySub(receipt, function cb(err, response) {
if (err) {
console.log('within err, was there a response? : ', response);
console.log('there was an error validating the subscription: ', err);
//console.log(err);
return true;
} else {
console.log('sucessfully validated the subscription');
// More Subscription info available in “response”
console.log('response is: ', response );
return true;
}
});
// return promises later.
还有其他人遇到过这个问题吗?
【问题讨论】:
-
我想知道是否有某种 google 配额,或者这可能是某种连接问题。如果出现该错误,我正在考虑仅重试 5-10 次,但这似乎很俗气且不可靠。
-
对此有何解决方案?
-
是的,请参阅下面的答案。
标签: node.js google-iap