I'm trying to write an if statement after a completed purchase. I'm using this tutorial.
purchase() {
if (!this.platform.is('cordova')) { return };
let productId;
if (this.platform.is('ios')) {
productId = this.product.appleProductID;
} else if (this.platform.is('android')) {
productId = this.product.googleProductID;
}
console.log('Products: ' + JSON.stringify(this.store.products));
console.log('Ordering From Store: ' + productId);
try {
let product = this.store.get(productId);
console.log('Product Info: ' + JSON.stringify(product));
let order = await this.store.order(productId);
alert('Finished Purchase');
} catch (err) {
console.log('Error Ordering ' + JSON.stringify(err));
}
}
I'm trying to load a new screen with data (content and gameGear), once the user completes the purchase:
goToReference() {
this.purchase();
if(this.purchase() === 'Finished Purchase'){
this.navCtrl.push(ReferencePage,{
content: this.content,
gameGear: this.gameGear
});
} else {
return
}
}
However the error I keep getting is:
Operator '===' cannot be applied to types 'Promise' and 'string'.
Not sure how to get around this issue or if there's easier syntax to fire off the this.purchase()
once the purchase has been completed.