in_app_purchases using flutter
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);
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Admin
Updated on December 13, 2022Comments
-
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 about 4 yearsYes, but we need a product which is not purchased yet.
-
Gorges about 4 yearsYou may use 'android.test.canceled' instead. developer.android.com/google/play/billing/billing_testing
-
Jawad Ahmed about 4 yearsBut we need to test on real ids.