所以事情就是这样——我有一个用于我的 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.
还有其他人遇到这个问题吗?