public async Task<bool?> IsBought(string Key) { try { if (IAPListingInformation == null) { IAPListingInformation = await Store.CurrentApp.LoadListingInformationAsync(); } if (IAPListingInformation.ProductListings.ContainsKey(Key)) { var productListing = IAPListingInformation.ProductListings[Key]; var liveInfo = Store.CurrentApp.LicenseInformation.ProductLicenses[productListing.ProductId].IsActive; return liveInfo; } else return null; } catch (Exception ex) { return null; } }
private async void InitializeLicensing() { #if DEBUG //Use Mock API instead of real store MockIAP.Init(); MockIAP.RunInMockMode(true); #if DONT_PRESERVE_LICENSE_INFO // Clear the cache every time. Remove this to have persistence. MockIAP.ClearCache(); #endif var sri = App.GetResourceStream (new Uri("Data\\MockupLicenseInfo.xml", UriKind.Relative)); XDocument doc = XDocument.Load(sri.Stream); string xml = doc.ToString(); MockIAP.SetListingInformation (1, "en-us", "Contoso Cookbooks sample app", "$5.99", "Contoso Cookbooks"); MockIAP.PopulateIAPItemsFromXml(xml); #endif #if SIMULATE_TRIAL Store.CurrentApp.LicenseInformation.IsTrial = true; #endif //Load associated product listings try { IAPListingInformation = await Store.CurrentApp.LoadListingInformationAsync(); } catch(Exception ex) { } }
private async void DoTapAction(string key) { if (!Store.CurrentApp.LicenseInformation.ProductLicenses[key].IsActive) { try { Store.ListingInformation li = await Store.CurrentApp.LoadListingInformationAsync(); string pID = li.ProductListings[key].ProductId; string receipt = await Store.CurrentApp.RequestProductPurchaseAsync(pID, false); } catch (Exception e) { } finally { Init(); } } }
public static async Task<ListingInformation> LoadListingInformationAsync() { MockIAP.CheckIfInitialized(); ListingInformation listingInformation; if (!MockIAP.MockMode) { Windows.ApplicationModel.Store.ListingInformation li = await Windows.ApplicationModel.Store.CurrentApp.LoadListingInformationAsync(); listingInformation = new ListingInformation(li); LicenseInformation = new LicenseInformation(Windows.ApplicationModel.Store.CurrentApp.LicenseInformation); } else { listingInformation = MockIAP.GetListingInformation(); listingInformation.ProductListings = MockIAP.allProducts; } return listingInformation; }
public static async Task<ListingInformation> LoadListingInformationByProductIdsAsync(string[] ProductIds) { MockIAP.CheckIfInitialized(); ListingInformation listingInformation; if (!MockIAP.MockMode) { Windows.ApplicationModel.Store.ListingInformation li = await Windows.ApplicationModel.Store.CurrentApp.LoadListingInformationByProductIdsAsync(ProductIds); listingInformation = new ListingInformation(li); } else { listingInformation = MockIAP.GetListingInformation(); listingInformation.ProductListings = new Dictionary<string, ProductListing>(); IEnumerable<string> result = from key in MockIAP.allProducts.Keys join pId in ProductIds on MockIAP.allProducts[key].ProductId equals pId select key; result.ToList().ForEach(k => listingInformation.ProductListings.Add(k, MockIAP.allProducts[k])); } return listingInformation; }
/// <summary> Loads Windows Store IAP informations. </summary> public async void LoadListingInfo() { StoreEvents.GetInstance().PostMarketItemsRefreshStartedEvent(); try { if (StoreConfig.STORE_TEST_MODE) { listingInfosMock = await MockStore.CurrentApp.LoadListingInformationAsync(); marketProductInfos.Clear(); if (listingInfosMock.ProductListings.Count > 0) { foreach (KeyValuePair <string, MockStore.ProductListing> pair in listingInfosMock.ProductListings) { MarketProductInfos marketProduct = new MarketProductInfos(); marketProduct.Name = pair.Value.Name; marketProduct.Description = pair.Value.Description; marketProduct.FormattedPrice = pair.Value.FormattedPrice; marketProduct.ImageUri = pair.Value.ImageUri; marketProduct.Keywords = pair.Value.Keywords; marketProduct.ProductId = pair.Value.ProductId; switch (pair.Value.ProductType) { case Windows.ApplicationModel.Store.ProductType.Consumable: marketProduct.ProductType = MarketProductInfos.MarketProductType.CONSUMABLE; break; case Windows.ApplicationModel.Store.ProductType.Durable: marketProduct.ProductType = MarketProductInfos.MarketProductType.DURABLE; break; case Windows.ApplicationModel.Store.ProductType.Unknown: marketProduct.ProductType = MarketProductInfos.MarketProductType.UNKNOWN; break; } marketProduct.Tag = pair.Value.Tag; marketProductInfos.Add(pair.Key, marketProduct); } } } else { listingInfos = await Store.CurrentApp.LoadListingInformationAsync(); IReadOnlyDictionary <string, Store.ProductListing> productListing; productListing = listingInfos.ProductListings; marketProductInfos.Clear(); if (productListing.Count > 0) { foreach (KeyValuePair <string, Store.ProductListing> pair in listingInfos.ProductListings) { MarketProductInfos marketProduct = new MarketProductInfos(); marketProduct.Name = pair.Value.Name; marketProduct.Description = pair.Value.Description; marketProduct.FormattedPrice = pair.Value.FormattedPrice; marketProduct.ImageUri = pair.Value.ImageUri; marketProduct.Keywords = pair.Value.Keywords; marketProduct.ProductId = pair.Value.ProductId; switch (pair.Value.ProductType) { case Windows.ApplicationModel.Store.ProductType.Consumable: marketProduct.ProductType = MarketProductInfos.MarketProductType.CONSUMABLE; break; case Windows.ApplicationModel.Store.ProductType.Durable: marketProduct.ProductType = MarketProductInfos.MarketProductType.DURABLE; break; case Windows.ApplicationModel.Store.ProductType.Unknown: marketProduct.ProductType = MarketProductInfos.MarketProductType.UNKNOWN; break; } marketProduct.Tag = pair.Value.Tag; marketProductInfos.Add(pair.Key, marketProduct); } } } } catch (Exception e) { SoomlaUtils.LogDebug(TAG, e.Message); } OnListingLoadedCB(marketProductInfos); }
/// <summary> Loads Windows Store IAP informations. </summary> public async void LoadListingInfo() { StoreEvents.GetInstance().PostMarketItemsRefreshStartedEvent(); try { if (StoreConfig.STORE_TEST_MODE) { listingInfosMock = await MockStore.CurrentApp.LoadListingInformationAsync(); marketProductInfos.Clear(); if (listingInfosMock.ProductListings.Count > 0) { foreach (KeyValuePair<string, MockStore.ProductListing> pair in listingInfosMock.ProductListings) { MarketProductInfos marketProduct = new MarketProductInfos(); marketProduct.Name = pair.Value.Name; marketProduct.Description = pair.Value.Description; marketProduct.FormattedPrice = pair.Value.FormattedPrice; marketProduct.ImageUri = pair.Value.ImageUri; marketProduct.Keywords = pair.Value.Keywords; marketProduct.ProductId = pair.Value.ProductId; switch (pair.Value.ProductType) { case Windows.ApplicationModel.Store.ProductType.Consumable: marketProduct.ProductType = MarketProductInfos.MarketProductType.CONSUMABLE; break; case Windows.ApplicationModel.Store.ProductType.Durable: marketProduct.ProductType = MarketProductInfos.MarketProductType.DURABLE; break; case Windows.ApplicationModel.Store.ProductType.Unknown: marketProduct.ProductType = MarketProductInfos.MarketProductType.UNKNOWN; break; } marketProduct.Tag = pair.Value.Tag; marketProductInfos.Add(pair.Key, marketProduct); } } } else { listingInfos = await Store.CurrentApp.LoadListingInformationAsync(); IReadOnlyDictionary<string, Store.ProductListing> productListing; productListing = listingInfos.ProductListings; marketProductInfos.Clear(); if (productListing.Count > 0) { foreach (KeyValuePair<string, Store.ProductListing> pair in listingInfos.ProductListings) { MarketProductInfos marketProduct = new MarketProductInfos(); marketProduct.Name = pair.Value.Name; marketProduct.Description = pair.Value.Description; marketProduct.FormattedPrice = pair.Value.FormattedPrice; marketProduct.ImageUri = pair.Value.ImageUri; marketProduct.Keywords = pair.Value.Keywords; marketProduct.ProductId = pair.Value.ProductId; switch (pair.Value.ProductType) { case Windows.ApplicationModel.Store.ProductType.Consumable: marketProduct.ProductType = MarketProductInfos.MarketProductType.CONSUMABLE; break; case Windows.ApplicationModel.Store.ProductType.Durable: marketProduct.ProductType = MarketProductInfos.MarketProductType.DURABLE; break; case Windows.ApplicationModel.Store.ProductType.Unknown: marketProduct.ProductType = MarketProductInfos.MarketProductType.UNKNOWN; break; } marketProduct.Tag = pair.Value.Tag; marketProductInfos.Add(pair.Key, marketProduct); } } } } catch (Exception e) { SoomlaUtils.LogDebug(TAG,e.Message); } OnListingLoadedCB(marketProductInfos); }