InAppPurchase play store example?

Hello everyone, i’m need to implement InAppPurchase, but i not clear at all.

In my play store console, i’ve created two products that they are ‘premium subscriptions’ and in my app i have this code:

public paySubscription(subscription: any): void {

        InAppPurchase
            .buy(subscription.productId)
            .then(data => InAppPurchase.consume(data.productType, data.receipt, data.signature))
            .then(() => {
                let prompt = this.alertCtrl.create({
                    title: 'Exito',
                    subTitle: 'Suscripcion adquerida!',
                    buttons: ['Aceptar']
                });
                prompt.present();
            })
            .catch( err => {
                console.log(err);
                let prompt = this.alertCtrl.create({
                    title: 'Error',
                    subTitle: err,
                    buttons: ['Aceptar']
                });
                prompt.present();
            })
    }

But, always i have an error, it go for the catch way and i see the message “Error Object object” and i can’t debug on my device.

Any example or something to do this? Maybe I’m doing it wrong

Than’s in advance!!

Ivan :slight_smile:

Hey, I actually had a ton of issues with this library but I ended up finding a different solution.

You should check out InAppPurchase2, which provides an event based system for making purchases. Then when you get an error you can handle it better.

I wrote a blog post about how to implement this

1 Like