Don't retrieve my purchases with in_app_purchase on flutter application

Viewed 97

I have a flutter application with in app purchase. For this, I use the library in_app_purchase. In appstoreconnect, I have 2 purchases validated. But when I try to get my purchases with the ids, it doesn't work. I don't retrieve mt purchases. This is the code:

Future<void> _getProducts() async {
print('_getProducts');
Set<String> ids = <String>['id1', 'id2'].toSet();
print(ids);
ProductDetailsResponse response = await _iap.queryProductDetails(ids).then((value) {
  print('aa');
  print(value.productDetails);
  print(value.notFoundIDs);
  print(value.error);
}).catchError((onError) {
  print('error _getProducts');
  print(onError);
});
print('bb');

setState(() {
  _products = response.productDetails;
  print(response.productDetails);
  if(response.productDetails.isNotEmpty){
    print(response.productDetails.elementAt(0));
  } else{
    print("void list");
  }
});
}

and this is the result:

enter image description here

So like you can see, I don't get the products but in fact, the function queryProductDetails is not even running.

And sometimes, I have a result but with my two ids in value.notFoundIDs.

So, do you know what I am doing wrong ?

  • Flutter version: Flutter 2.5.3
  • Dart 2.14.4
  • in_app_purchase: ^1.0.9
0 Answers
Related