3

#in_app_purchase I'm using in_app_purchase in my flutter app. https://pub.dev/packages/in_app_purchase Firstly I was using RevenueCat services for my IAP services but due to the unavailability of purchase tokens from Revenue Cat. I decided to use flutter official's in_app_purchase. Apparently in this approach when I query for all my products from Google Play. The program is stuck at

InAppPurchase.instance.queryProductDetails();

method and isn't giving any response. Not even an error. I have also initiated the InAppPurchase instance but still, it's getting me the issue. Can anybody please help figure this out?

  • Does this answer your question? [In-app purchase doesn't return any response](https://stackoverflow.com/questions/69756327/in-app-purchase-doesnt-return-any-response) – user3413723 Aug 23 '23 at 08:40

2 Answers2

5

I was battling against the same problem and finally found the solution.

This part needs to be removed from the app-level build.gradle file in order for in_app_purchase to work properly. Once I removed these two lines, everything worked flawlessly.

def billing_version = "4.0.0"
implementation "com.android.billingclient:billing:$billing_version"

This it terribly misleading, since the in_app_purchase package links to the "Getting started" guide for Google Play, which explicitly says to add these two lines.

Ronald Blüthl
  • 311
  • 4
  • 9
0

First you have to make some products by uploading your app to the play store. You have to have correct app identifier. But also your emulator must support google play store:

There are a bunch of setup steps. But if you run this code and it turns out the problem is that it's not available, it's probably because you have an emulator that doesn't work.

enter image description here Need to get the one with the Play Store icon

enter image description here

If you have problems, try this code to prove the problem is the emulator:

final bool available = await InAppPurchase.instance.isAvailable();
    if (!available) {
      print("store is not available");
      error = "Store not available";
      notifyListeners();
      return;
    }
user3413723
  • 11,147
  • 6
  • 55
  • 64