不一致 - "用于调用Google Play Developer API的项目ID尚未在Google Play开发者控制台中关联."

Jef*_*ett 1 node.js google-iap

所以这就是事情 - 我的Android应用程序有一个node.js后端服务器.我正在使用Google Play结算库,并使用后端验证购买是否为Google文档推荐.

现在,有关此错误的所有其他答案似乎都是指一致的问题.

我的后端SOMETIMES验证,有时会将此作为错误返回,表明我的服务帐户实际上是链接的(如我的控制台中所示).

我尝试了两个不同的库,我有同样的问题.有时一个人会回复验证成功,而另一个人会说我的帐户没有关联.有时他们都是消极的,有时都是积极的.

这似乎不一致.

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;
        }
    });
Run Code Online (Sandbox Code Playgroud)

我也试过一个不同的库,得到了相同的结果:

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.
Run Code Online (Sandbox Code Playgroud)

还有其他人遇到这个问题?

Jef*_*ett 8

我终于找到了答案.问题不在于我的代码,也不在Google Developer Console或Google Play控制台中.除了一件事,一切都正确设置.

以前,在Google Play控制台中设置测试许可帐户之前,我已在产品ID"X"上使用真钱进行了实际的订购购买.

然后,在添加作为测试用户购买订阅的相同Google帐户后,我继续测试相同订阅的结果,productID"X".

即使我取消了REAL购买,实际到期日期也不是另一个月.

因此,我相信当我购买/取消购买时,谷歌有时会感到困惑 - 将测试订阅与真实订阅混淆.

创建新的产品ID,只使用它,解决了我的问题,并且一致地验证了购买.