From 19c2c14f021031d9c148585dda2e93b49c6353d3 Mon Sep 17 00:00:00 2001 From: Robin Seinen <16294492+RobinS-S@users.noreply.github.com> Date: Thu, 6 May 2021 10:28:53 +0200 Subject: [PATCH] [iOS] Handle Apple NSUnderlyingError instead of failing on GeneralError when Terms & Conditions have changed --- src/Plugin.InAppBilling/InAppBilling.apple.cs | 6 ++++-- .../Shared/InAppBillingExceptions.shared.cs | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Plugin.InAppBilling/InAppBilling.apple.cs b/src/Plugin.InAppBilling/InAppBilling.apple.cs index af41e98..bc62b02 100644 --- a/src/Plugin.InAppBilling/InAppBilling.apple.cs +++ b/src/Plugin.InAppBilling/InAppBilling.apple.cs @@ -254,7 +254,9 @@ async Task 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; @@ -269,7 +271,7 @@ async Task 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; diff --git a/src/Plugin.InAppBilling/Shared/InAppBillingExceptions.shared.cs b/src/Plugin.InAppBilling/Shared/InAppBillingExceptions.shared.cs index 209a6d5..df42ebe 100644 --- a/src/Plugin.InAppBilling/Shared/InAppBillingExceptions.shared.cs +++ b/src/Plugin.InAppBilling/Shared/InAppBillingExceptions.shared.cs @@ -69,7 +69,8 @@ public enum PurchaseError NotOwned, FeatureNotSupported, ServiceDisconnected, - ServiceTimeout + ServiceTimeout, + AppleTermsConditionsChanged } ///