Skip to content

Commit

Permalink
Fix ProductRequestDelegate so it throws invalid product exception.
Browse files Browse the repository at this point in the history
InvalidProducts was never handled so previously it was always returning null Products instead of throwing exception.
  • Loading branch information
winnicki committed Apr 22, 2021
1 parent c2f6356 commit adfe7f4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Plugin.InAppBilling/InAppBilling.apple.cs
Expand Up @@ -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"));
}
}

Expand Down

0 comments on commit adfe7f4

Please sign in to comment.