From 7e095351c5c2007fe6939bfbbe0bd45a46403198 Mon Sep 17 00:00:00 2001 From: Sebastian Kruse Date: Tue, 22 Jan 2019 09:09:56 +0100 Subject: [PATCH] Validate iOS purchases on restore --- .../InAppBillingImplementation.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Plugin.InAppBilling.iOS/InAppBillingImplementation.cs b/src/Plugin.InAppBilling.iOS/InAppBillingImplementation.cs index 60fe6f6..7a89906 100644 --- a/src/Plugin.InAppBilling.iOS/InAppBillingImplementation.cs +++ b/src/Plugin.InAppBilling.iOS/InAppBillingImplementation.cs @@ -108,10 +108,14 @@ public async override Task> GetPurchasesAsync( .Select(p2 => p2.ToIABPurchase()) .Distinct(comparer); - //try to validate purchases - var valid = await ValidateReceipt(verifyPurchase, string.Empty, string.Empty); + var validPurchases = new List(); + foreach (var purchase in converted) + { + if (await ValidateReceipt(verifyPurchase, purchase.ProductId, purchase.Id)) + validPurchases.Add(purchase); + } - return valid ? converted : null; + return validPurchases.Any() ? validPurchases : null; }