verifyPurchase method

  1. @override
PurchaseStatus verifyPurchase({
  1. required PurchaseDetails purchaseDetail,
})
override

Verifies the status of purchases.

Parameters:

  • purchaseDetail Purchased item to verify.

Implementation

@override
PurchaseStatus verifyPurchase({required PurchaseDetails purchaseDetail}) {
  bool isValidID = _productIds.any((id) => id == purchaseDetail.productID);

  if (purchaseDetail.status == PurchaseStatus.restored && isValidID) {
    return PurchaseStatus.restored;
  } else if (purchaseDetail.status == PurchaseStatus.purchased && isValidID) {
    return PurchaseStatus.purchased;
  }
  return PurchaseStatus.error;
}