'cordova-plugin-purchase: iOS does not do anything even after calling order

We are using Ionic and cordova-plugin-purchase (also known as In App Purchase 2) to implement purchasing subscriptions. Android is working perfectly fine--it's iOS that is giving us a lot of problems.

Calling the order function with the name of the product should show iOS purchase popup and the purchase should just continue as usual.

However, after calling the order function, the subscription product's status becomes requested but nothing happens after that. No pop-ups appear. The weird thing is that, just yesterday, we were able to purchase the product, and after that subscription expired, we were able to purchase it again. It worked just fine. However, today, after the product expired again, clicking the order function just updates the product's status to requested but nothing happens after that. Purchase is also working perfectly fine on Android--it's just iOS that is extremely weird and always producing errors and problems. Sometimes, when we change sandbox accounts and use a new one, it works, but sometimes, it just suddenly stops working.

We tried simplifying the code as much as possible to the point that only these are the important parts:

    // this just automatically sets the validator to the correct URL which changes depending on the user's ID.
    this.subscriptions.add(
      this.status.userData.subscribe(data => {
        this.userData = data;
        this.store.validator = `https://xxxxxxxxxxx/api/app/users/${ data.id }/purchased`;
      })
    );

    this.store.register([
      {
        id: this.MONTHLY_SUBSCRIPTION,
        type: this.store.PAID_SUBSCRIPTION
      },
      {
        id: this.YEARLY_SUBSCRIPTION,
        type: this.store.PAID_SUBSCRIPTION
      }
    ]);

    this.store.error((error) => {
      console.log('ERROR', error);
    });

    this.store.when(this.YEARLY_SUBSCRIPTION).updated((p) => {
      this.yearly = p;
      console.log('yearly', p.state);
    });

    this.store.when(this.MONTHLY_SUBSCRIPTION).updated((p) => {
      this.monthly = p;
      console.log('month', p.state);
    });

    this.store.when(this.YEARLY_SUBSCRIPTION)
        .approved(p => p.verify())
        .verified(p => p.finish())
        .owned(p => this.continue(true, p.id));

    this.store.when(this.MONTHLY_SUBSCRIPTION)
        .approved(p => p.verify())
        .verified(p => p.finish())
        .owned(p => this.continue(true, p.id));

    this.store.refresh();

Calling this.store.order(this.MONTHLY_SUBSCRIPTION); does not do anything. The funny part is calling this.store.order(this.YEARLY_SUBSCRIPTION); does show iOS purchase pop-up. There are no error outputs or anything. We also did try using this.store.autoFinishTransactions = true; before this.store.refresh(); but that didn't seem to do anything.

We have been getting no luck lately and if anyone could offer suggestions or tips on how to fix this (maybe it's an error in the plugin? I did try submitting an issue, but...)

Thank you very much in advance, and I would gladly provide any further information if needed.



Solution 1:[1]

According to the plugin's documentation, store.register() takes an object, not an array. That could be why it is only registering the last product.

store.register({
    id: "cc.fovea.inapp1",
    alias: "full version",
    type: store.NON_CONSUMABLE
});

https://github.com/j3k0/cordova-plugin-purchase/blob/master/doc/api.md#register

Another possibility I can think of is your MONTHLY_SUBSCRIPTION's value may not be matching the Product Id of your In App Purchase item on app store connect.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MIWMIB