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

后端 未结 3 1055
情书的邮戳
情书的邮戳 2020-12-13 14:47

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

3条回答
  •  萌比男神i
    2020-12-13 15:13

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

提交回复
热议问题