Скачал плагин и установил из ionic-native
Мой код:
public product: any = {
name: 'My Product',
googleProductId: 'com.yourapp.prod1'
};
configurePurchasing() {
if (!this.platform.is('cordova')) { return; }
let productId;
try {
if (this.platform.is('android')) {
productId = this.product.googleProductId;
}
this.store.verbosity = this.store.DEBUG;
this.store.register({
id: productId,
alias: productId,
type: this.store.NON_RENEWING_SUBSCRIPTION
});
this.registerHandlers(productId);
this.store.when(productId).error( (error) => {
alert('An Error Occured' + JSON.stringify(error));
});
console.log('Refresh Store');
this.store.refresh();
} catch (err) {
console.log('Error On Store Issues' + JSON.stringify(err));
}
}
registerHandlers(productId) {
this.store.when(productId).approved( (product: IAPProduct) => {
product.finish();
});
this.store.when(productId).registered( (product: IAPProduct) => {
console.log('Registered: ' + JSON.stringify(product));
});
this.store.when(productId).updated( (product: IAPProduct) => {
console.log('Loaded' + JSON.stringify(product));
});
this.store.when(productId).cancelled( (product) => {
alert('Purchase was Cancelled');
});
this.store.error( (err) => {
alert('Store Error ' + JSON.stringify(err));
});
}
async purchase() {
if (!this.platform.is('cordova')) { return };
let productId;
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));
}
}
Скажите пожалуйста что такое com.yourapp.prod1 и "My Product" и где его взять.