Google Play 应用内购买返回错误代码 -1008:null puchaseData 或 dataSignature

Posted

技术标签:

【中文标题】Google Play 应用内购买返回错误代码 -1008:null puchaseData 或 dataSignature【英文标题】:Google Play In-App Purchase returns error code -1008: null puchaseData or dataSignature 【发布时间】:2013-04-28 23:15:58 【问题描述】:

在 v2 中成功实现 Google Play in-app purchase v3 后,我正在尝试实现它。但是,每次我尝试购买我真正的应用内产品时,都会收到以下后续错误:

IAB 返回 null purchaseData 或 dataSignature(响应 -1008:未知错误)

这是来自IabHelper.java class, line 452:

if (purchaseData == null || dataSignature == null) 
    logError("BUG: either purchaseData or dataSignature is null.");
    logDebug("Extras: " + data.getExtras().toString());
    result = new IabResult(IABHELPER_UNKNOWN_ERROR, "IAB returned null purchaseData or dataSignature");
    if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null);
    return true;

我已验证 a) 我的应用已签名,b) 我的应用版本与 Google Play 商店中的草稿版本# 相匹配,并且 c) 尝试购买的用户已被添加为测试用户。我已经在 3 个测试帐户和 4 个应用内购买订阅类型中进行了尝试。

我应该关注这个错误代码吗? 此问题是否仅限于非生产版本? 如果/当我发布此版本时,这会影响我在现场的客户吗? 您真的只能在您实际使用 IAB 版本 3 实时发布应用内购买后对它进行端到端测试吗?我意识到我可以使用 android.test.purchased 项目类型,并且我有(它有效),但我不认为这是一个有效的端到端测试。

【问题讨论】:

【参考方案1】:

对于 Cordova 和 Hybrid 应用,您需要使用this.iap.subscribe(this.productId) 方法订阅InAppPurchase

以下是对我来说可以正常工作的代码:

 getProdutIAP() 
        this.navCtrl.push('subscribeDialogPage');
        this.iap
            .getProducts(['productID1']).then((products: any) => 
                this.buy(products);
                // alert('getProdutIAP' + JSON.stringify(products));
            )
            .catch((err) => 
                console.log(JSON.stringify(err));
                alert('Finished Purchase' + JSON.stringify(err));
                console.log(err);
            );
    

    buy(products: any) 
        // this.getProdutIAP();
        // alert(products[0].productId);
        this.iap.subscribe(products[0].productId).then((buydata: any) => 
            alert('buy Purchase' + JSON.stringify(buydata));
            // this.sub();
        ).catch((err) => 
            // this.navCtrl.push('subscribeDialogPage');
            alert('buyError' + JSON.stringify(err));
        );
    

    sub() 
        this.platform.ready().then(() => 
            this.iap
                .subscribe(this.productId)
                .then((data) => 
                    console.log('subscribe Purchase' + JSON.stringify(data));
                    alert('subscribe Purchase' + JSON.stringify(data));
                    this.getReceipt();
                ).catch((err) => 
                    this.getReceipt();
                    alert('subscribeError' + JSON.stringify(err));
                    console.log(err);
                );
        )
    

【讨论】:

【参考方案2】:

错误购买:iabResult:IAB 返回 null 购买数据或数据 签名(响应:-1008 未知错误)

如果您在使用 launchPurchaseFlow() 方法时遇到上述错误并收到此错误,请检查您的产品类型。我创建了订阅,但我需要托管产品,例如非消耗性产品类型。我的意思是谨慎购买或订阅

【讨论】:

【参考方案3】:

我自己也遇到过这个问题。过了一会儿,我发现我做错了什么。我在 IABHelper 上调用了错误的方法。

如果您使用在 Google Developer Console 上注册为订阅的 SKU 调用 mHelper.launchPurchaseFlow(...),则会导致错误: IAB 返回 null purchaseData 或 dataSignature(响应 -1008:未知错误)。

如果您有注册为订阅的 SKU,则必须改用以下方法:mHelper.launchSubscriptionPurchaseFlow(...)

希望这会有所帮助。

【讨论】:

谢谢!就是这样。 Google Play 开发者确实回复了,但从未回复我解决方案。我欠你一个(字面意思)! 虽然我使用了正确的项目类型和方法,但我得到了同样的错误。应用内购买有效,订阅无效。 launchSubscriptionPurchaseFlow() 方法依次调用带有 itemType 为“IabHelper.ITEM_TYPE_INAPP”的 launchPurchaseFlow()。因此,如果您在 launchPurchaseFlow() 中传递正确的 itemType,则没有区别。我使用了正确的项目类型,但仍然出现同样的错误!!!! 轰隆隆!很高兴看到这个答案,我担心我会调试几个小时。 Sree -- 不正确,launchSubscriptionPurchaseFlow() 使用 itemType IabHelper.ITEM_TYPE_SUBS 调用 launchPurchaseFlow()。

以上是关于Google Play 应用内购买返回错误代码 -1008:null puchaseData 或 dataSignature的主要内容,如果未能解决你的问题,请参考以下文章

Google 应用内购买始终会获得退款

如何在 Android 中测试 Google Play 计费订阅(非应用内购买)

应用内购买:获取请求购买的 Google Play 帐户的名称或 ID

Google Play:使用来自不同国家/地区的设置测试应用内购买?

无法在 Google Play 开发者控制台中创建应用内购买

如何让应用内购买项目在 Google Play 上显示给播放器