Exemple #1
0
        public static PurchaseError ToPurchaseError(this BillingResponseCode code)
        {
            PurchaseError error;

            switch (code)
            {
            case BillingResponseCode.BillingUnavailable:
                error = PurchaseError.BillingUnavailable;
                break;

            case BillingResponseCode.DeveloperError:
                error = PurchaseError.DeveloperError;
                break;

            case BillingResponseCode.Error:
                error = PurchaseError.GeneralError;
                break;

            case BillingResponseCode.FeatureNotSupported:
                error = PurchaseError.GeneralError;
                break;

            case BillingResponseCode.ItemAlreadyOwned:
                error = PurchaseError.AlreadyOwned;
                break;

            case BillingResponseCode.ItemNotOwned:
                error = PurchaseError.NotOwned;
                break;

            case BillingResponseCode.ItemUnavailable:
                error = PurchaseError.ItemUnavailable;
                break;

            case BillingResponseCode.ServiceDisconnected:
                error = PurchaseError.ServiceDisconnected;
                break;

            case BillingResponseCode.ServiceTimeout:
                error = PurchaseError.NetworkConnectionFailed;
                break;

            case BillingResponseCode.ServiceUnavailable:
                error = PurchaseError.ServiceUnavailable;
                break;

            case BillingResponseCode.UserCancelled:
                error = PurchaseError.UserCancelled;
                break;

            default:
                error = PurchaseError.Unknown;
                break;
            }

            return(error);
        }
Exemple #2
0
        /// <summary>
        /// Returns Exception if return code is not OK
        /// </summary>
        /// <param name="billingResponseCode"></param>
        /// <returns></returns>
        private InAppBillingPurchaseException GetErrorCode(BillingResponseCode billingResponseCode)
        {
            switch (billingResponseCode)
            {
            case BillingResponseCode.Ok:
                return(null);

            case BillingResponseCode.BillingUnavailable:
                return(new InAppBillingPurchaseException(PurchaseError.BillingUnavailable));

            case BillingResponseCode.DeveloperError:
                return(new InAppBillingPurchaseException(PurchaseError.DeveloperError));

            case BillingResponseCode.Error:
                return(new InAppBillingPurchaseException(PurchaseError.GeneralError));

            case BillingResponseCode.FeatureNotSupported:
                return(new InAppBillingPurchaseException(PurchaseError.FeatureNotSupported));

            case BillingResponseCode.ItemAlreadyOwned:
                return(null);

            case BillingResponseCode.ItemNotOwned:
                return(new InAppBillingPurchaseException(PurchaseError.NotOwned));

            case BillingResponseCode.ItemUnavailable:
                return(new InAppBillingPurchaseException(PurchaseError.ItemUnavailable));

            case BillingResponseCode.ServiceDisconnected:
                return(new InAppBillingPurchaseException(PurchaseError.ServiceDisconnected));

            case BillingResponseCode.ServiceTimeout:
                return(new InAppBillingPurchaseException(PurchaseError.ServiceTimeout));

            case BillingResponseCode.ServiceUnavailable:
                return(new InAppBillingPurchaseException(PurchaseError.ServiceUnavailable));

            case BillingResponseCode.UserCancelled:
                return(new InAppBillingPurchaseException(PurchaseError.UserCancelled));

            default:
                return(new InAppBillingPurchaseException(PurchaseError.GeneralError));
            }
        }