From adfe7f4e13cfd75f0ece9691e5859ab90e473b63 Mon Sep 17 00:00:00 2001 From: Derek Winnicki Date: Thu, 22 Apr 2021 13:48:13 -0400 Subject: [PATCH] Fix ProductRequestDelegate so it throws invalid product exception. InvalidProducts was never handled so previously it was always returning null Products instead of throwing exception. --- src/Plugin.InAppBilling/InAppBilling.apple.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Plugin.InAppBilling/InAppBilling.apple.cs b/src/Plugin.InAppBilling/InAppBilling.apple.cs index 24318db..af41e98 100644 --- a/src/Plugin.InAppBilling/InAppBilling.apple.cs +++ b/src/Plugin.InAppBilling/InAppBilling.apple.cs @@ -400,15 +400,19 @@ class ProductRequestDelegate : NSObject, ISKProductsRequestDelegate, ISKRequestD public void ReceivedResponse(SKProductsRequest request, SKProductsResponse response) { - var product = response.Products; + var invalidProduct = response.InvalidProducts; + if (invalidProduct?.Any() ?? false) + { + tcsResponse.TrySetException(new InAppBillingPurchaseException(PurchaseError.InvalidProduct, $"Invalid Product: {invalidProduct.First()}")); + return; + } + var product = response.Products; if (product != null) { tcsResponse.TrySetResult(product); return; } - - tcsResponse.TrySetException(new InAppBillingPurchaseException(PurchaseError.InvalidProduct, "Invalid Product")); } }