Error - The Item that you were attempting to purchase could not be found

Hey All

I am trying to implement a subscription service in my Ionic 4 app. I am able to get the products from the play store, but when I try to subscribe to one of the products, I get the following: Error - The Item that you were attempting to purchase could not be found.

Your code / steps to reproduce

In the app.component.ts, I call the InAppPurchase.getProduct() method and all products are returned.

this.iap.getProducts([. . . products . . .])
      .then((products: InAppProductVO[]) => {
        console.log("Purchased Products: ", products);        
      })
      .catch((err) => {
        console.error("Failed to get purchases products", err);
        return Promise.reject(err);
      })

Then, when the user selects a subscription option, I do a check (still in progress, always fails) to see if they already have an active subscription. If not, I call the subscribe method.

this.iap.subscribe(productId)
          .then((product) => {
            // Don't get here :(
          })
          .catch((err) => {
            console.error(`Unable to purchase subscription - ${productId}: `, err);
            return loading.dismiss()
              .then(() => {
                return Promise.reject("You need to purchase this content to view it.");
              });
          })

Console output

I get the following on the device and no error messages returned in console.

Screenshot_2019-07-25-10-51-23

Type of product you are working with consumable/non-consumable/subscription

Product Type: Subscription

Version of cordova

Cordova CLI : 8.1.2 (cordova-lib@8.1.1)
Ionic CLI : 5.2.3

Version of iOS/Android

Android: 6.0.0

Additional Info

All my products are marked as active on the play store.
Billing is activated and an APK with the billing key has been uploaded and is published on the store.

I have tested the IAP (in-app-purchases) on multiple devices after Iwas able to get it to work on my bosses phone (FYI: Same code)

Working Devices:

  • Samsung s10 - Android 9.0, OneUI 1.1

Devices that aren’t working:

  • Samsung s8 - Android 9.0, OneUI 1.0
  • Huawei p9lite - Android 6.0, EMUI 4.1.3 (my device)
  • Samsung J5 Prime - Android 7.0, Samsung Experience 8.1

When it started to work on my bosses s10, I thought that it may have to do with the Huawei ban, but after not being able to get the IAP to work on 2 other Samsung’s, I do not believe that it is the issue after all. I shall continue to test and try different things and shall comment any findings here.

Has anybody had this error before and how were you able to resolve it?
Any help with this would be much appreciated.

FYI, this is a copy of the following Github issue of Alex Disler’s plugin. I am posting here to get it everywhere possible in the hope it will reach as many people as possible :slight_smile: .

By no means is this issue solved, but I have been able to solve it. Confused? Let me explain the best I can based on how I understand this problem. FYI, I am still very confused by this.

Short Answer: Create new subscriptions

Long Answer:
So after a lot of searching on the web, reading many tutorials on how to implement a subscription service, watching YouTube video’s on how to do it and reading as many forum posts as I could find I just gave up as I did not know what is wrong or how to fix it. Let it be known that by this time I had spent 3 days on the problem!

My boss then had an idea to create a managed product on the store and see if I could buy that in my app. I did that and implemented a basic buy() method based on the documentation and VWALA , just like that it was working I was able to buy a product. Not a subscription but a product. This then lead me to believe that I did something wrong when creating my subscriptions. SO… back I went to the documentation, tutorials and various online forums to try and see what I did wrong. After spending some time and not getting a definitive answer I just went for it. I created a new subscription, added it in my app and it all worked as expected. I was able to buy subscriptions in-app.

But how you may be asking? I don’t know. I have not the faintest idea on what I did differently. All I can think of is that somewhere, something went wrong on Google’s side as the ‘error’ I was getting came straight from google and not the plugin. What I think it may be is that I created the subscriptions while the app was still in review and not actually published yet. Other than that your best guess is as good (perhaps even better) than mine.

If anybody has encountered this before, please would you explain how you solved this problem?

1 Like