chap
chap

Reputation: 9

cordova-plugin-purchase unable to find product

I want to use the cordova-plugin-purchase plugin in my Android Cordova app.

The app exists on the Google Play Console, but I installed the .apk manually, without any test track on my physical device (logged in with the correct account). I want to test the library with static responses from Google.

In my Cordova code I can register the product, initialize the store and get the product without errors. But when I request an offer and call order() on that object, a message pops up:

the item you want to buy could not be found

Here is some code:


const { store, ProductType, Platform } = CdvPurchase;
store.register([
  {
    type: ProductType.CONSUMABLE,
    id: "my_test_product_id",
    platform: Platform.GOOGLE_PLAY,
  },
]);
await store.initialize([Platform.GOOGLE_PLAY]);
const product = store.get("my_test_product_id", Platform.GOOGLE_PLAY);
const offer = product.getOffer();
offer.order();

store.initalize() returns an empty array, so I think there were no errors. When I try to register an invalid 'foo' id, initalize() returns an error element.

Could it be, that it does not recognize that I want to run the order() function in test mode? Under which criteria does the test mode apply?

I am confused because, store.get() returns the correct product, but it fails when I want to use it.

Upvotes: 0

Views: 189

Answers (1)

omeroglu
omeroglu

Reputation: 41

It might be related to how you try to make a purchase. If you are using your local environment, that can be the issue. Make sure you choose the right environment.

Upvotes: 0

Related Questions