Google Play In-App Purchase returns error code -1008: null puchaseData or dataSignature
Asked Answered
L

3

27

I am attempting to implement Google Play in-app purchase v3, after successfully implementing it in v2. However, every single time I attempt to purchase one of my real in-app products, I receive the following follow-up error:

IAB returned null purchaseData or dataSignature (response -1008:Unknown error)

This is coming from the 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;
}

I have verified that a) my app is signed, b) the version of my app matches the draft version # on the Google Play store, and c) the user attempting the purchase has been added as a test user. I have tried this across 3 test accounts and 4 in-app purchase subscription types.

  • Should I be concerned about this error code?
  • Is this an issue confined only to non-production releases?
  • Will this affect my customers in the field if/when I release this version?
  • Can you really only test in-app purchase end-to-end once you actually published it live with IAB version 3? I realize I can use the android.test.purchased item type, and I have (it works), but I don't consider that a valid end-to-end test.
Lactoprotein answered 4/5, 2013 at 18:45 Comment(0)
H
71

I had this problem myself. After a while I found what I did wrong. I was calling the wrong method on the IABHelper.

If you call mHelper.launchPurchaseFlow(...) with an SKU that is registered as a subscription on Google Developer Console it will result in the error: IAB returned null purchaseData or dataSignature (response -1008:Unknown error).

If you have a SKU that is registered as an subscription you have to use the method: mHelper.launchSubscriptionPurchaseFlow(...) instead.

Hope this helps.

Hautrhin answered 26/5, 2013 at 14:27 Comment(5)
THANK YOU! That was it. Google Play developer did reply but never got back to me with the solution. I owe you one (literally)!Lactoprotein
I got the same error though i am using the correct item type and method. In-App purchases works, subscriptions not.Ker
launchSubscriptionPurchaseFlow() method in turn calls launchPurchaseFlow() with itemType as 'IabHelper.ITEM_TYPE_INAPP'. So if you pass correct itemType in launchPurchaseFlow(), it makes no difference. I am using correct item type, but still getting the same error!!!!Epiblast
Boom! So nice to see this answer, I was worried I'd be debugging this for hours.Preterhuman
Sree -- incorrect, launchSubscriptionPurchaseFlow() calls launchPurchaseFlow() with itemType IabHelper.ITEM_TYPE_SUBS.Angstrom
D
1

error purchasing: iabResult: IAB returned null purchase Data or data Signature (response: -1008 unknown error)

if you get above error when you use launchPurchaseFlow() method and get this error check your product type. i was created subscriptions but i needed managed products for example Non-consumable product type. I mean be carefully about buying or subscriptions

Danczyk answered 14/1, 2018 at 14:9 Comment(0)
J
1

For Cordova and Hybrid apps you need to use this.iap.subscribe(this.productId) method to subscription InAppPurchase.

Following are the code working fine for me:

 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);
                });
        })
    }
Jennifferjennilee answered 31/1, 2019 at 10:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.