Answer the question
In order to leave comments, you need to log in
How to complete the purchase cycle in ionic-native/in-app-purchase-2?
Documentation In App Purchase 2
Essence:
Application on Ionic 4 / Cordova / Angular 8
Installed In App Purchase 2 , Sandbox accounts are configured, and the Apple account itself.
Product registration goes well:
registerProduct() {
this.iap.verbosity = this.iap.DEBUG;
this.iap.register({
id: MONEYCOMBO_KEY,
type: this.iap.CONSUMABLE
})
this.registerHandlersForPurchase(MONEYCOMBO_KEY)
this.product = this.iap.get(MONEYCOMBO_KEY)
this.iap.refresh()
this.iap.when(MONEYCOMBO_KEY).updated((p) => {
this.product = p
this.title = p.title
this.price = p.price
})
}
registerHandlersForPurchase(productId) {
let self = this.iap;
this.iap.when(productId).updated(function (product) {
if (product.loaded && product.valid && product.state === self.APPROVED && product.transaction != null) {
product.finish();
}
});
this.iap.when(productId).registered((product: IAPProduct) => {
// alert(` owned ${product.owned}`);
});
this.iap.when(productId).owned((product: IAPProduct) => {
console.error('finished')
product.finish();
});
this.iap.when(productId).approved((product: IAPProduct) => {
// alert('approved');
product.finish();
});
this.iap.when(productId).refunded((product: IAPProduct) => {
// alert('refunded');
});
this.iap.when(productId).expired((product: IAPProduct) => {
// alert('expired');
});
}
buyMoneyCombo(form: NgForm) {
this.registerHandlersForPurchase(MONEYCOMBO_KEY)
this.date = form.value.date
this.iap.order(MONEYCOMBO_KEY)
this.iap.refresh()
}
"InAppPurchase[js]: product test has a transaction in progress: 1000000628239595"
Answer the question
In order to leave comments, you need to log in
The problem was solved by deep analysis of the code.
It turned out that the message
"InAppPurchase[js]: product test has a transaction in progress: 1000000628239595"
this.iap.when(MONEYCOMBO_KEY).approved((product: IAPProduct) => {
product.finish()
this.getMoney()
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question