Skip to content

Commit

Permalink
put more guards on underlying issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontemagno committed May 6, 2021
1 parent c7362a8 commit a0d0f3c
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions src/Plugin.InAppBilling/InAppBilling.apple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,24 +255,30 @@ async Task<SKPaymentTransaction> PurchaseAsync(string productId)
var errorCode = tran?.Error?.Code ?? -1;
var description = tran?.Error?.LocalizedDescription ?? string.Empty;
var error = PurchaseError.GeneralError;
var underlyingError = tran?.Error?.UserInfo?["NSUnderlyingError"] as NSError;
switch (errorCode)
{
case (int)SKError.PaymentCancelled:
error = PurchaseError.UserCancelled;
break;
case (int)SKError.PaymentInvalid:
error = PurchaseError.PaymentInvalid;
break;
case (int)SKError.PaymentNotAllowed:
error = PurchaseError.PaymentNotAllowed;
break;
case (int)SKError.ProductNotAvailable:
error = PurchaseError.ItemUnavailable;
break;
case (int)SKError.Unknown:
error = underlyingError?.Code == 3038 ? PurchaseError.AppleTermsConditionsChanged : PurchaseError.GeneralError;
{
case (int)SKError.PaymentCancelled:
error = PurchaseError.UserCancelled;
break;
case (int)SKError.PaymentInvalid:
error = PurchaseError.PaymentInvalid;
break;
case (int)SKError.PaymentNotAllowed:
error = PurchaseError.PaymentNotAllowed;
break;
case (int)SKError.ProductNotAvailable:
error = PurchaseError.ItemUnavailable;
break;
case (int)SKError.Unknown:
try
{
var underlyingError = tran?.Error?.UserInfo?["NSUnderlyingError"] as NSError;
error = underlyingError?.Code == 3038 ? PurchaseError.AppleTermsConditionsChanged : PurchaseError.GeneralError;
}
catch
{
error = PurchaseError.GeneralError;
}
break;
case (int)SKError.ClientInvalid:
error = PurchaseError.BillingUnavailable;
Expand Down

0 comments on commit a0d0f3c

Please sign in to comment.