Skip to content

Commit

Permalink
[iOS] Handle Apple NSUnderlyingError instead of failing on GeneralErr…
Browse files Browse the repository at this point in the history
…or when Terms & Conditions have changed
  • Loading branch information
RobinS-S committed May 6, 2021
1 parent 39cda2a commit 19c2c14
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/Plugin.InAppBilling/InAppBilling.apple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ async Task<SKPaymentTransaction> PurchaseAsync(string productId)
var errorCode = tran?.Error?.Code ?? -1;
var description = tran?.Error?.LocalizedDescription ?? string.Empty;
var error = PurchaseError.GeneralError;
switch (errorCode)
var underlyingError = tran?.Error?.UserInfo?["NSUnderlyingError"] as NSError;

switch (errorCode)
{
case (int)SKError.PaymentCancelled:
error = PurchaseError.UserCancelled;
Expand All @@ -269,7 +271,7 @@ async Task<SKPaymentTransaction> PurchaseAsync(string productId)
error = PurchaseError.ItemUnavailable;
break;
case (int)SKError.Unknown:
error = PurchaseError.GeneralError;
error = underlyingError?.Code == 3038 ? PurchaseError.AppleTermsConditionsChanged : PurchaseError.GeneralError;
break;
case (int)SKError.ClientInvalid:
error = PurchaseError.BillingUnavailable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public enum PurchaseError
NotOwned,
FeatureNotSupported,
ServiceDisconnected,
ServiceTimeout
ServiceTimeout,
AppleTermsConditionsChanged
}

/// <summary>
Expand Down

0 comments on commit 19c2c14

Please sign in to comment.