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
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
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.
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);
});
})
}