Hi there. I am using ionic 3 and in app purchase 2@4. I use this code in .ts file
const six_months_membership = 'six_months_membership';
const three_months_membership = 'three_months_membership';
const one_month_membership = 'one_month_membership';
const yearly_membership = 'yearly_membership';
products: IAPProduct[] = [];
constructor(...) {
this.platform.ready().then(() => {
this.store.verbosity = this.store.DEBUG;
this.registerProducts();
this.setupListeners();
this.store.ready(() => {
this.products = this.store.products;
this.ref.detectChanges();
});
});
}
registerProducts() {
this.store.register({
id: one_month_membership,
alias: one_month_membership,
type: this.store.PAID_SUBSCRIPTION
});
this.store.register({
id: three_months_membership,
alias: three_months_membership,
type: this.store.PAID_SUBSCRIPTION
});
this.store.register({
id: six_months_membership,
alias: six_months_membership,
type: this.store.PAID_SUBSCRIPTION
});
this.store.register({
id: yearly_membership,
alias: yearly_membership,
type: this.store.PAID_SUBSCRIPTION
});
this.store.refresh();
}
setupListeners() {
this.store.when('product')
.approved((p: IAPProduct) => {
if (p.id === one_month_membership) {
console.log("one month approved");
}
else if (p.id === three_months_membership) {
console.log("three month approved");
}
else if (p.id === six_months_membership) {
console.log("six month approved");
}
else if (p.id === yearly_membership) {
console.log("yearly approved");
}
else {
console.log("none approved");
}
this.ref.detectChanges();
return p.verify();
p.finish();
});
}
on first time google play products came succesfully on the page and here is the debug;
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: state: one_month_membership -> registered
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: state: three_months_membership -> registered
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: state: six_months_membership -> registered
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: state: yearly_membership -> registered
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: store.trigger -> triggering action refreshed
ion-dev.js?v=3.2.4:157 InAppBilling[js]: setup ok
ion-dev.js?v=3.2.4:157 InAppBilling[js]: load ["one_month_membership","three_months_membership","six_months_membership","yearly_membership"]
ion-dev.js?v=3.2.4:157 InAppBilling[js]: listener: {"type":"ready","data":{}}
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: plugin -> ready
ion-dev.js?v=3.2.4:157 InAppBilling[js]: getAvailableProducts()
ion-dev.js?v=3.2.4:157 fatal_error
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: plugin -> loaded - [{"skuDetailsToken":"AEuhp4I6S37b0Gnw9eG-H_tNdOLUIn_gYvRJ7D0JeysqHBzObygydcrAiCT8-SsbGx1k","productId":"one_month_membership","type":"subs","price":"₺14,90","price_amount_micros":14900000,"price_currency_code":"TRY","subscriptionPeriod":"P1M","title":"Aylık Abonelik (BetLiveRadar)","description":"Aylık abonelik. Sonraki ay otomatik olarak yenilenecektir."},{"skuDetailsToken":"AEuhp4JtPS9oW0bjxUI7Wsk_iZSXjWt5k4Dl90WqKnvYNCEyKPbNW6MI4WUzSEpLXu_w","productId":"six_months_membership","type":"subs","price":"₺65,90","price_amount_micros":65900000,"price_currency_code":"TRY","subscriptionPeriod":"P6M","title":"6 Aylık Abonelik (BetLiveRadar)","description":"6 aylık aboneliği kapsar. Süre sonunda otomatik olarak yenilenir."},{"skuDetailsToken":"AEuhp4Jof9oHMl70PhO1XnYSlQbI7pSmGzgkIp-zGvSfP6x7F1GT41PLXa34Rol1J6ge","productId":"three_months_membership","type":"subs","price":"₺38,90","price_amount_micros":38900000,"price_currency_code":"TRY","subscriptionPeriod":"P3M","title":"3 Aylık Abonelik (BetLiveRadar)","description":"3 aylık abonelik. 3 ay sonunda otomatik yenilenir."},{"skuDetailsToken":"AEuhp4K4RLmOmNsLoULqodBtiOfSVXgNed-OuunjjxmIRZHhL8m7vmXF0MHwrQGea4da","productId":"yearly_membership","type":"subs","price":"₺118,90","price_amount_micros":118900000,"price_currency_code":"TRY","subscriptionPeriod":"P1Y","title":"Yıllık Abonelik (BetLiveRadar)","description":"1 yıllık aboneliği kapsar. Süre sonunda otomatik olarak yenilenir."}]
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: state: one_month_membership -> valid
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: state: six_months_membership -> valid
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: state: three_months_membership -> valid
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: state: yearly_membership -> valid
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: iabGetPurchases()
ion-dev.js?v=3.2.4:157 InAppBilling[js]: getPurchases()
ion-dev.js?v=3.2.4:157 InAppBilling[js]: listener: {"type":"setPurchases","data":{"purchases":[]}}
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: iabSetPurchases: []
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: inappbilling.getPurchases() -> Success
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: -> object
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: -> []
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: iabUpdatePurchases: []
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: store.trigger -> triggering action refresh-completed
but when i refresh the page the debug code like this;
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: state: one_month_membership -> registered
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: state: three_months_membership -> registered
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: state: six_months_membership -> registered
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: state: yearly_membership -> registered
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: store.trigger -> triggering action refreshed
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: refresh -> checking products state (8 products)
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: refresh -> product id one_month_membership (one_month_membership)
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: in state 'valid'
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: refresh -> product id three_months_membership (three_months_membership)
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: in state 'valid'
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: refresh -> product id six_months_membership (six_months_membership)
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: in state 'valid'
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: refresh -> product id yearly_membership (yearly_membership)
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: in state 'valid'
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: refresh -> product id one_month_membership (one_month_membership)
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: in state 'registered'
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: refresh -> product id three_months_membership (three_months_membership)
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: in state 'registered'
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: refresh -> product id six_months_membership (six_months_membership)
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: in state 'registered'
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: refresh -> product id yearly_membership (yearly_membership)
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: in state 'registered'
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: store.trigger -> triggering action re-refreshed
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: iabGetPurchases()
ion-dev.js?v=3.2.4:157 InAppBilling[js]: getPurchases()
ion-dev.js?v=3.2.4:157 InAppBilling[js]: listener: {"type":"setPurchases","data":{"purchases":[]}}
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: iabSetPurchases: []
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: inappbilling.getPurchases() -> Success
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: -> object
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: -> []
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: store.trigger -> triggering action refresh-completed
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: iabUpdatePurchases: []
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: state: one_month_membership -> valid
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: state: three_months_membership -> valid
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: state: six_months_membership -> valid
ion-dev.js?v=3.2.4:157 [store.js] DEBUG: state: yearly_membership -> valid
ion-dev.js?v=3.2.4:157 fatal_error
shows products but can not get title, description etc. and add empty objects on the page.
So i really don’t know my miskate and how can i adjust to fix this issue.
best regards.
1 post - 1 participant