in_app_purchases using flutter

910

You need to use a reserved SKU for the test: android.test.purchased

const Set<String> _kIds = {'android.test.purchased'};
final ProductDetailsResponse response =
    await InAppPurchaseConnection.instance.queryProductDetails(_kIds);
Share:
910
Admin
Author by

Admin

Updated on December 13, 2022

Comments

  • Admin
    Admin over 1 year

    I am trying to create an application that can handle In App Purchases Using Flutter.I am using the in_app_purchase 0.2.1 plugin .I have managed to setup my product on google play developer console as required but however when try to retrieve it from the application i am able to connect to the store successfully but i am not able to retrieve my product ,it always shows up as product not found.

    I have followed a this tutorial https://joebirch.co/2019/05/31/adding-in-app-purchases-to-flutter-apps/ and also looked at the package documentation https://pub.dev/packages/in_app_purchase. My google play setup for the product is shown below google play console setup google play console setup2

    The function i am using is shown below.

      Future<List<ProductDetails>> retrieveProducts() async {
    final bool available = await InAppPurchaseConnection.instance.isAvailable();
    if (!available) {
      // Handle store not available
      print("Store Temporarily Unavailable");
      return null;
    } else {
      print("Store Temporarily Available");
      const Set<String> _kIds = {'airtime123'};
      final ProductDetailsResponse response =
          await InAppPurchaseConnection.instance.queryProductDetails(_kIds);
      if (response.notFoundIDs.isNotEmpty) {
        print("product not found");
        print(response.notFoundIDs[0]);
        return null;
      }
      print("product found");
      return response.productDetails;
    }
    

    }

    This is the result i get

    I/flutter ( 7254): Store Temporarily Available
    I/flutter ( 7254): product not found
    
    I/flutter ( 7254): airtime123
    
  • Altay Hunoğlu
    Altay Hunoğlu about 4 years
    Yes, but we need a product which is not purchased yet.
  • Gorges
    Gorges about 4 years
    You may use 'android.test.canceled' instead. developer.android.com/google/play/billing/billing_testing
  • Jawad Ahmed
    Jawad Ahmed about 4 years
    But we need to test on real ids.