I have a video list page.on click video i have to check is video is purchased or owned. so write code like this.
gotoVideo(video:any){
alert(JSON.stringify(video))
if(video.product_id == null || video.product_id == ''){
this.navCtrl.push(SingleVideoPage,{video:video,user_type:"student"});
}else{
if(video.owned == true){
//go
this.navCtrl.push(SingleVideoPage,{video:video,user_type:"student"});
}else{
let iapProduct:IAPProduct = this.store.products.find(p => p.id == video.product_id);
this.store.order(iapProduct).then(p => {
// Purchase in progress!
// alert(JSON.stringify(p))
}, e => {
// alert(JSON.stringify(e))
this.presentAlert(`Failed to purchase: ${e}`);
}).catch((e)=>{
// alert(JSON.stringify(e))
});
this.store.when('product')
.owned((p: IAPProduct) => {
alert('owned')
p.finish();
this.ref.detectChanges();
return p.verify();
});
this.store.when('product')
.approved((p: IAPProduct) => {
alert('approved')
p.finish();
this.ref.detectChanges();
return p.verify();
});
}
}
}
But it doesnt work. always owned:false in sandbox
How to achive this.please help me.