Flutter in app purchase, productDetails is empty...any idea why?

798 Views Asked by At

So, I've developed an app with Flutter in-app-purchase. I've configured everything on App Store Connect, created a sandbox user, etc...

However, when I run the app, but productDetails is empty...I'm testing in Testflight. Is that the issue? Should I submit it?

2

There are 2 best solutions below

1
On

OK, I figured it out. The product id was wrong.

0
On

If you use code similar to the one below to fetch your purchases, make sure your _kIds purchase ids in code are identical to those in Play Console.

Future<void> loadPurchases() async {
    final available = await iapConnection.isAvailable();
    if (available) {
      const Set<String> _kIds = <String>{'product1', 'product2'};
      final ProductDetailsResponse response =
          await InAppPurchase.instance.queryProductDetails(_kIds);
      if (response.notFoundIDs.isNotEmpty) {
        // Handle the error.
      }
      List<ProductDetails> products = response.productDetails;
      print('Products are $products');
    } else {
      print('Store not available');
    }
  }