getPurchaseList method

  1. @override
Future<List<ProductDetails?>?> getPurchaseList(
  1. List<String> purchase_ids,
  2. String purchase_type,
  3. PurchaseListener? listener
)
override

Implementation

@override
Future<List<ProductDetails?>?> getPurchaseList(List<String> purchase_ids,
    String purchase_type, PurchaseListener? listener) async {
  this.listener = listener;
  final List<PurchaseId> pricingList = [];

  purchase_ids.forEach((element) {
    pricingList
        .add(PurchaseId(purchaseId: element, purchaseType: purchase_type));
  });

  final price = await methodChannel.invokeMethod<String?>(
      'getPurchaseList', {"purchases": purchaseIdToJson(pricingList)});
  if ((price ?? "").isEmpty) {
    return List.empty();
  }
  final List<ProductDetails> retrievePricingList = [];
  productDetailsResponseFromJson(price!).forEach((element) {
    if ((element.zza ?? "").isNotEmpty) {
      retrievePricingList.add(productDetailsFromJson(element.zza!));
    }
  });
  print(
      "ZZA ==>  ${retrievePricingList.length}    --->     ${jsonEncode(retrievePricingList)}");
  return retrievePricingList;
}