Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] Handle Apple NSUnderlyingError instead of failing on GeneralError when Terms & Conditions have changed #382

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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