I am beginner in ionic 3 and want to implemet in app purchase plugin of cordova in my ionic 3 application. I add plugin according to documentation [https://github.com/j3k0/cordovapluginpurchase/blob/master/doc/api.md#storerefresh]
but when i call store.buy(productid). It breaks and give error “Function is not defined”.
this.store.verbosity = this.store.DEBUG;
this.store.register({
id: 'com.test_app.initapp,
alias: "100 cents",
type: this.store.CONSUMABLE
});
try {
let product = this.store.get(this.productId);
if (!product) {
alert("Not a product");
}
else if (product.state != this.store.REGISTERED) {
alert("Product un registered");
}
else if (product.state === this.store.INVALID) {
alert("Product invalid");
}
else {
// Product loaded and valid.
console.log('Product Info: ' + JSON.stringify(product));
alert("Getproduct"+product+this.store.validator);
}
this.store.order(productid).then( () => {
console.log('Purchase Succesfull');
this.loader.dismiss();
alert('Purchase Succesfull');
}).catch( (err) => {
console.log('Error Ordering From Store'+JSON.stringify(err));
alert("Error ordering from store."+err.message);
// this.loader.dismiss();
});
}
catch (err) {
console.log('Error Ordering ' + JSON.stringify(err));
alert("Error from ordering:"+JSON.stringify(err.message));
// this.loader.dismiss();
}
Console Output:
console.log: [store.js] DEBUG: queries ++ ‘com.test_app.initapp approved’
[19:50:43] console.log: [store.js] DEBUG: queries ++ ‘com.test_app.initapp registered’
[19:50:43] console.log: [store.js] DEBUG: queries ++ ‘com.test_app.initapp updated’
[19:50:43] console.log: [store.js] DEBUG: queries ++ ‘com.test_app.initapp cancelled’
[19:50:43] console.log: [store.js] DEBUG: queries ++ ‘com.test_app.initapp error’
[19:50:43] console.log: Product Info: {“id”:“com.test_app.initapp”,“alias”:“100 cents”,“type”:“consumable”,“state”:“registered”,“title”:null,“description”:null,“priceMicros”:null,“price”:null,“currency”:null,“loaded”:false,“canPurchase”:false,“owned”:false,“downloading”:false,“downloaded”:false,“additionalData”:null,“transaction”:null}
After Click on Buy button:
This is the error i get and everything breaks.
[19:50:57] console.log: [store.js] DEBUG: queries ++ ‘com.test_app.initapp initiated’
[19:50:57] console.log: Error Ordering {“line”:659,“column”:21,“sourceURL”:“http://192.168.1.5:8100/build/main.js”}
It breaks and give error “Function is not defined”.
Please help me out i am stuck at this point from last 2 days and i am totally exhausted.
If anyone integrate it please guide me.