protected async override Task <IEnumerable <InAppBillingPurchase> > GetPurchasesAsync(ItemType itemType, IInAppBillingVerifyPurchase verifyPurchase, string verifyOnlyProductId) { var purchases = await RestoreAsync(); if (purchases == null) { return(null); } var comparer = new InAppBillingPurchaseComparer(); var converted = purchases .Where(p => p != null) .Select(p2 => p2.ToIABPurchase()) .Distinct(comparer); var validPurchases = new List <InAppBillingPurchase>(); foreach (var purchase in converted) { if ((verifyOnlyProductId != null && !verifyOnlyProductId.Equals(purchase.ProductId)) || await ValidateReceipt(verifyPurchase, purchase.ProductId, purchase.Id)) { validPurchases.Add(purchase); } } return(validPurchases.Any() ? validPurchases : null); }
public async override Task <IEnumerable <InAppBillingPurchase> > GetPurchasesAsync(ItemType itemType) { var purchases = await RestoreAsync(); var comparer = new InAppBillingPurchaseComparer(); return(purchases ?.Where(p => p != null) ?.Select(p2 => p2.ToIABPurchase()) ?.Distinct(comparer)); }
/// <summary> /// Get all current purchase for a specifiy product type. /// </summary> /// <param name="itemType">Type of product</param> /// <param name="verifyPurchase">Interface to verify purchase</param> /// <returns>The current purchases</returns> public async override Task <IEnumerable <InAppBillingPurchase> > GetPurchasesAsync(ItemType itemType, IInAppBillingVerifyPurchase verifyPurchase = null) { var purchases = await RestoreAsync(); if (purchases == null) { return(null); } var comparer = new InAppBillingPurchaseComparer(); var converted = purchases .Where(p => p != null) .Select(p2 => p2.ToIABPurchase()) .Distinct(comparer); //try to validate purchases var valid = await ValidateReceipt(verifyPurchase, string.Empty, string.Empty); return(valid ? converted : null); }