public async override Task RefreshAppProducts()
        {
            AppProducts.Clear();

            var listingInfo = await GetListingInformationAsync();

            foreach (var product in listingInfo.ProductListings)
            {
                var license = GetLicense(product.Value.ProductId);

                AppProduct appProduct = new AppProduct(license.ProductId, license.ProductId, false);
                appProduct.Name                  = product.Value.Name;
                appProduct.Description           = product.Value.Description;
                appProduct.CurrentFormattedPrice = product.Value.FormattedPrice;
                appProduct.BaseFormattedPrice    = product.Value.FormattedBasePrice;
                appProduct.ExpiryDate            = license.ExpirationDate.DateTime;
                appProduct.Purchased             = license.IsActive;
                if (license.IsConsumable)
                {
                    appProduct.ProductType = ProductKind.Consumable;
                }
                else
                {
                    appProduct.ProductType = ProductKind.Durable;
                }

                AppProducts.Add(appProduct);
            }

            // Invoke the event
            InvokeAppProductsChanged();
        }
        public async override Task RefreshAppProducts()
        {
            var kinds = GetProductKinds();

            var appLicense = await Context.GetAppLicenseAsync();

            var result = await Context.GetAssociatedStoreProductsAsync(kinds.Select(x => x.ToString()));

            AppProducts.Clear();
            foreach (var item in result.Products)
            {
                Debug.WriteLine($"Key: {item.Key} | StoreID: {item.Value.StoreId} | ProductID: {item.Value.InAppOfferToken}");

                // Cache the value
                var storeProduct = item.Value;

                // Create the App Product
                AppProduct appProduct = new AppProduct(storeProduct.InAppOfferToken, storeProduct.StoreId);
                appProduct.Name                  = storeProduct.Title;
                appProduct.Description           = storeProduct.Description;
                appProduct.CurrentFormattedPrice = storeProduct.Price.FormattedPrice;
                appProduct.BaseFormattedPrice    = storeProduct.Price.FormattedBasePrice;

                // Parse the Product Type
                if (Enum.TryParse <ProductKind>(storeProduct.ProductKind, out ProductKind parsedProductKind))
                {
                    appProduct.ProductType = parsedProductKind;
                }
                else
                {
                    appProduct.ProductType = ProductKind.Unknown;
                }

                // Add License Info
                appProduct.Purchased = storeProduct.IsInUserCollection;
                foreach (var license in appLicense.AddOnLicenses)
                {
                    Debug.WriteLine($"Licence Key: {license.Key} == Product Key: {item.Key}");
                    if (license.Key.Contains(item.Key))
                    {
                        appProduct.Purchased  = license.Value.IsActive;
                        appProduct.ExpiryDate = license.Value.ExpirationDate.DateTime;
                        Debug.WriteLine($"Licence Found - Purchased: {appProduct.Purchased} | Expiry Date: {appProduct.ExpiryDate}");
                        break;
                    }
                }

                // Finally, add to the main list
                Debug.WriteLine(appProduct);
                AppProducts.Add(appProduct);
            }

            InvokeAppProductsChanged();
        }
        public async Task <(AppProduct, PurchaseResults)> Purchase(string id)
        {
            var license = GetLicense(id);

            // If the product does not exist, exit with null
            if (license == null)
            {
                Debug.WriteLine("This product does not exist");
                throw new ArgumentException($"A product by ProductID of {id} does not exist", nameof(AppProduct.ProductID));
                //return (null, null);
            }

            // If the license is valid, but we don't have the product, create the product
            var product = GetAppProductByProductID(id);

            if (product == null)
            {
                product = new AppProduct(id, id, false);
                AppProducts.Add(product);
            }

            // If the license is already active, simply return the product
            if (license.IsActive)
            {
                Debug.WriteLine("User already owns this product");
                return(product, null);
            }

            try
            {
                PurchaseResults purchaseResults;

                if (DebugHelpers.DebugMode)
                {
                    Debug.WriteLine("Debug mode active, Simulating product purchase");
                    purchaseResults = await CurrentAppSimulator.RequestProductPurchaseAsync(id);

                    Debug.WriteLine("Finished Simulating");
                }
                else
                {
                    Debug.WriteLine("Requesting Product Purchase");
                    purchaseResults = await CurrentApp.RequestProductPurchaseAsync(id);

                    Debug.WriteLine("User finished interacting with purchase screen");
                }

                switch (purchaseResults.Status)
                {
                case ProductPurchaseStatus.AlreadyPurchased:
                    Debug.WriteLine("User already owns this product");
                    MarkProductPurchased(product);
                    break;

                case ProductPurchaseStatus.Succeeded:
                    Debug.WriteLine("User now owns this product");
                    MarkProductPurchased(product);
                    break;

                case ProductPurchaseStatus.NotPurchased:
                    Debug.WriteLine("User chose to not purchase the product");
                    product.Purchased = false;
                    if (DebugHelpers.DebugMode)
                    {
                        Debug.WriteLine("Simulating Purchase");
                        MarkProductPurchased(product);
                    }
                    break;

                case ProductPurchaseStatus.NotFulfilled:
                    Debug.WriteLine("A previous purchase was not fulfilled");
                    MarkProductPurchased(product);
                    break;

                default:
                    Debug.WriteLine("An unknown response occurred. Please try again later");
                    break;
                }

                return(product, purchaseResults);
            }
            catch (Exception ex)
            {
                ExceptionHelpers.PrintOutException(ex, $"Product Purchase Error ({id})");
            }

            return(product, null);
        }