Skip to content

Commit

Permalink
Merge pull request #377 from winnicki/master
Browse files Browse the repository at this point in the history
Fix ProductRequestDelegate so it throws invalid product exception.
  • Loading branch information
jamesmontemagno committed Apr 22, 2021
2 parents c2f6356 + adfe7f4 commit 3ee3475
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Plugin.InAppBilling/InAppBilling.apple.cs
Original file line number Diff line number Diff line change
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 3ee3475

Please sign in to comment.