//Metodo para verificara compra de IAP public async void Verificar_CompraIAPs() { try { var listing = await CurrentApp.LoadListingInformationAsync(); // Select the right product, use the information that we used when submitting the in-app purchase to the store var product = listing.ProductListings.FirstOrDefault(p => p.Value.ProductId == "AdBlocker" && p.Value.ProductType == ProductType.Durable); try { // Verifica se o produto já foi comprado! if (CurrentApp.LicenseInformation.ProductLicenses["AdBlocker"].IsActive) { Home_ADS.Visibility = Visibility.Collapsed; } else { } } catch { } } catch { } }
public async void restoreCompletedTransactions(string args) { try { // get all in-app products for current app ListingInformation productList = await CurrentApp.LoadListingInformationAsync(); foreach (KeyValuePair <string, ProductListing> product in productList.ProductListings) { ProductLicense productLicense = null; if (CurrentApp.LicenseInformation.ProductLicenses.TryGetValue(product.Key, out productLicense)) { if (productLicense.IsActive) { this.DispatchCommandResult(new PluginResult(PluginResult.Status.OK, product.Key)); } } } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.ToString()); this.DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Unknown Error")); } }
public static async Task <string> GetPriceAsync(string productKey, string offlineText) { string price = "Purchase"; if (NetworkInterface.GetIsNetworkAvailable() == true) { try { ListingInformation listings = await CurrentApp.LoadListingInformationAsync(); ProductListing product = listings.ProductListings[productKey]; price = product.FormattedPrice; } catch { price = offlineText; } } else { price = offlineText; } return(price); }
public async Task CheckLicenceFeaturepack() { #if DEBUG _isFeaturepackLicensed = true; return; #endif try { var listing = await CurrentApp.LoadListingInformationAsync(); var featurepackLicence = listing.ProductListings.FirstOrDefault(p => p.Value.ProductId == FeaturepackProductKey); if (CurrentApp.LicenseInformation.ProductLicenses != null) { _isFeaturepackLicensed = CurrentApp.LicenseInformation.ProductLicenses[featurepackLicence.Key].IsActive; } } catch (Exception ex) { if (!ex.Message.Contains("0x805A0194")) { InsightHelper.Report(ex); } } }
internal async void GetPrice() { try { #if DEBUG ListingInformation listing = await CurrentAppSimulator.LoadListingInformationAsync(); #else ListingInformation listing = await CurrentApp.LoadListingInformationAsync(); #endif List <string> ps = new List <string>(); foreach (var item in DonationPack) { var product = listing.ProductListings[item]; ps.Add(product.FormattedPrice); } Price = ps.ToArray(); licenseChangeHandler = new LicenseChangedEventHandler(licenseChangedEventHandler); #if DEBUG CurrentAppSimulator.LicenseInformation.LicenseChanged += licenseChangeHandler; #else CurrentApp.LicenseInformation.LicenseChanged += licenseChangeHandler; #endif } catch (Exception) { Price = null; } }
private async void upgradePro() { try { var listing = await CurrentApp.LoadListingInformationAsync(); var superweapon = listing.ProductListings.FirstOrDefault(p => p.Value.ProductId == "proUpgrade" && p.Value.ProductType == ProductType.Durable); try { if (CurrentApp.LicenseInformation.ProductLicenses[superweapon.Value.ProductId].IsActive) { appSettings.saveSettingsBool(appSettings.ProEnabled, true); MessageBox.Show("You already own the pro upgrade, the purchase has been restored.", "Restored", MessageBoxButton.OK); } else { string receipt = await CurrentApp.RequestProductPurchaseAsync(superweapon.Value.ProductId, true); appSettings.saveSettingsBool(appSettings.ProEnabled, true); MessageBox.Show("Thank you for purchasing the pro upgrade. You can now use the pro features! :).", "Awesome", MessageBoxButton.OK); } } catch (Exception ex) { MessageBox.Show("Cannot purchase at the moment."); } } catch { Debug.WriteLine("ayyy pro upgrade aint working mate"); } }
private async Task getProductDetails() { if (PBAApplication.getInstance().IsPremiumUser()) { VisibilityMode = Visibility.Collapsed; CurrentLicense = "You have already upgraded to premium service"; } else { VisibilityMode = Visibility.Visible; CurrentLicense = "Currently you are using free version of the app"; try { //ListingInformation li = await CurrentAppSimulator.LoadListingInformationAsync(); ListingInformation li = await CurrentApp.LoadListingInformationAsync(); ProductListing pListing; if (li.ProductListings.TryGetValue("premium_user", out pListing)) { PremiumPrice = pListing.FormattedPrice; } else { PremiumPrice = "1.00 USD"; } } catch (Exception ex) { PremiumPrice = "1.00 USD"; } } }
protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (App.IsFree) { if (App.ListingInfo == null) { try { App.ListingInfo = await CurrentApp.LoadListingInformationAsync(); } catch { } } if (App.ListingInfo != null && App.ListingInfo.ProductListings.ContainsKey(App.AdFreeIAP)) { var iapListing = App.ListingInfo.ProductListings[App.AdFreeIAP]; btnRemoveAds.Content = String.Format("{0} - {1}", btnRemoveAds.Content, iapListing.FormattedPrice); btnRemoveAds.Visibility = Windows.UI.Xaml.Visibility.Visible; } } else { btnRemoveAds.Visibility = Windows.UI.Xaml.Visibility.Collapsed; } }
async private void btnBuy50Points_Click_1(object sender, RoutedEventArgs e) { //50 Points - Consumable var listing = await CurrentApp.LoadListingInformationAsync(); var fiftypoints = listing.ProductListings.FirstOrDefault(p => p.Value.ProductId == "11111" && p.Value.ProductType == ProductType.Consumable); try { receipt = await CurrentApp.RequestProductPurchaseAsync(fiftypoints.Value.ProductId, true); if (CurrentApp.LicenseInformation.ProductLicenses[fiftypoints.Value.ProductId].IsActive) { // do something CurrentApp.ReportProductFulfillment(fiftypoints.Value.ProductId); m_pointCount += 50; txtBought50Pts.Visibility = System.Windows.Visibility.Visible; txtBought50Pts.Text = "Bought 50 Points " + i++ + " times for a total of " + m_pointCount + "!"; } } catch (Exception ex) { //catch exception } }
async private void btnBuySuperWeapon_Click_1(object sender, RoutedEventArgs e) { //Super Weapon - Durable var listing = await CurrentApp.LoadListingInformationAsync(); var superweapon = listing.ProductListings.FirstOrDefault(p => p.Value.ProductId == "22222" && p.Value.ProductType == ProductType.Durable); try { if (CurrentApp.LicenseInformation.ProductLicenses[superweapon.Value.ProductId].IsActive) { MessageBox.Show("You already own this weapon!"); } else { receipt = await CurrentApp.RequestProductPurchaseAsync(superweapon.Value.ProductId, true); txtBoughtSW.Visibility = System.Windows.Visibility.Visible; txtBoughtSW.Text = "You own the Super Weapon Now!"; } } catch (Exception ex) { //catch exception } }
private async void btnListAllProducts_Click_1(object sender, RoutedEventArgs e) { try { StringBuilder sb = new StringBuilder(); var listing = await CurrentApp.LoadListingInformationAsync(); foreach (var product in listing.ProductListings) { sb.AppendLine(string.Format("{0}, {1}, {2},{3}, {4}", product.Value.ProductId, product.Value.Name, product.Value.FormattedPrice, product.Value.ProductType, product.Value.Description)); } MessageBox.Show(sb.ToString(), "List all products", MessageBoxButton.OK); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButton.OK); } }
public async Task <InAppPurchaseHelper> Setup() { // license if (Simulate) { #if DEBUG await SetupSimulation(); m_License = CurrentAppSimulator.LicenseInformation; m_Listing = await CurrentAppSimulator.LoadListingInformationAsync(); CanPurchase = true; #endif } else { try { m_License = CurrentApp.LicenseInformation; m_Listing = await CurrentApp.LoadListingInformationAsync(); CanPurchase = true; } catch (Exception e) { System.Diagnostics.Debug.WriteLine(string.Format("Setup/License [{0}, {1}, {2}]", this.Key, this.Simulate, e.Message)); CanPurchase = false; } } if (!CanPurchase) { return(this); // :( } try { // test setup m_License.LicenseChanged += () => { RaiseLicenseChanged(IsPurchased); }; IReadOnlyDictionary <string, ProductLicense> _Licenses = m_License.ProductLicenses; if (!_Licenses.Any(x => x.Key.Equals(Key, StringComparison.CurrentCultureIgnoreCase))) { throw new KeyNotFoundException(Key); } IReadOnlyDictionary <string, ProductListing> _Products = m_Listing.ProductListings; if (!_Products.Any(x => x.Key.Equals(Key, StringComparison.CurrentCultureIgnoreCase))) { throw new KeyNotFoundException(Key); } // product m_Product = _Products[Key]; } catch (Exception e) { System.Diagnostics.Debug.WriteLine(string.Format("Setup/Tests [{0}, {1}, {2}]", this.Key, this.Simulate, e.Message)); CanPurchase = false; } return(this); }
/// <summary> /// Get Windows Store product matching a MEGA product /// </summary> /// <param name="megaProductId">MEGA product identifier to match</param> /// <returns>Windows Store product or NULL if none available</returns> public static async Task <ProductListing> GetProductAsync(string megaProductId) { try { if (string.IsNullOrEmpty(megaProductId)) { return(null); } var listing = await CurrentApp.LoadListingInformationAsync(); if (listing == null || !listing.ProductListings.Any()) { return(null); } var result = listing.ProductListings.First( p => p.Key.ToLower().Equals(megaProductId.ToLower())); return(result.Value); } catch (Exception e) { LogService.Log(MLogLevel.LOG_LEVEL_ERROR, string.Format("Failure retrieving store product for {0}", megaProductId), e); return(null); } }
private async void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) { prods = await CurrentApp.LoadListingInformationAsync(); products.ItemsSource = prods.ProductListings.Values.Select(x => new { x.Name, Status = CurrentApp.LicenseInformation.ProductLicenses[x.ProductId].IsActive ? "Purchased" : x.FormattedPrice, x.ImageUri, x.ProductId, BuyNowButtonVisible = CurrentApp.LicenseInformation.ProductLicenses[x.ProductId].IsActive ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible }); progressRing.IsActive = false; }
/// <summary> /// Loads the app's listing information asynchronously. /// </summary> /// <returns></returns> public static async Task <ListingInformation> LoadListingInformationAsync() { #if DEBUG return(ListingInformation.Create(await CurrentAppSimulator.LoadListingInformationAsync())); #else return(ListingInformation.Create(await CurrentApp.LoadListingInformationAsync())); #endif }
private async Task <ListingInformation> GetListings() { if (_listings == null) { _listings = await CurrentApp.LoadListingInformationAsync(); } return(_listings); }
private static async void GetProductListing(object state) { try { App.ListingInfo = await CurrentApp.LoadListingInformationAsync(); } catch { } }
/// <summary> /// Gets the formatted price of the app /// </summary> /// <returns>an async task with the formatted price of the app as a string</returns> internal static async Task <string> GetPriceAsync() { #if DEBUG var listingInformation = await CurrentAppSimulator.LoadListingInformationAsync(); #else var listingInformation = await CurrentApp.LoadListingInformationAsync(); #endif return(listingInformation.FormattedPrice); }
public static async Task <ListingInformation> GetAvailableCheersAddOn() { using (var releaser = await _InitializeLock.LockAsync()) { var listing = await CurrentApp.LoadListingInformationAsync(); return(listing); } }
private static async void LoadListing(Action <ListingInformation, Exception> onComplete) { try { #if DEBUG var task = CurrentApp.LoadListingInformationAsync(); #else var task = CurrentApp.LoadListingInformationAsync().AsTask(); #endif await task; var information = task.Result; if (information != null) { var listing = new ListingInformation(); listing.AgeRating = information.AgeRating; listing.CurrentMarket = information.CurrentMarket; listing.Description = information.Description; listing.FormattedPrice = information.FormattedPrice; listing.Name = information.Name; listing.ProductListings = new Dictionary <string, ProductListing>(); var productListings = information.ProductListings; foreach (var productListing in productListings) { var value = productListing.Value; var product = new ProductListing(); product.ProductId = value.ProductId; product.ProductType = (ProductType)value.ProductType; product.FormattedPrice = value.FormattedPrice; product.Name = value.Name; listing.ProductListings.Add(productListing.Key, product); } if (onComplete != null) { EtceteraWindows.RunOnUnityThread(() => onComplete(listing, null)); } } else { if (onComplete != null) { EtceteraWindows.RunOnUnityThread(() => onComplete(null, new Exception("ListingInformation is null"))); } } } catch (Exception ex) { if (onComplete != null) { EtceteraWindows.RunOnUnityThread(() => onComplete(null, ex)); } } }
public async static Task <string> GetPremiumPriceAsync() { var listings = await CurrentApp.LoadListingInformationAsync(); if (listings.ProductListings.ContainsKey("VoiceMemosPremium")) { return(listings.ProductListings["VoiceMemosPremium"].FormattedPrice); } return(null); }
public static async Task <string> getProductPrice() { #if DEBUG ListingInformation information = await CurrentAppSimulator.LoadListingInformationAsync(); #else ListingInformation information = await CurrentApp.LoadListingInformationAsync(); #endif List <ProductListing> products = information.ProductListings.Values.ToList(); ProductListing product = products.Single(x => x.ProductId == prodotto); return(product.FormattedPrice); }
private async void OnDonateButtonClick(object sender, RoutedEventArgs args) { using (ProgressRingViewer.Show()) { MessageDialog dialog = new MessageDialog(""); try { ListingInformation info = await CurrentApp.LoadListingInformationAsync(); ProductListing donation; if (info.ProductListings.TryGetValue("donation", out donation)) { if (await FulfillDonation()) { PurchaseResults purchaseResult = await CurrentApp.RequestProductPurchaseAsync(donation.ProductId); if (purchaseResult.Status == ProductPurchaseStatus.Succeeded) { dialog.Content = ResourceLoader.GetForCurrentView().GetString("thanksForDonation") + "\n" + ResourceLoader.GetForCurrentView().GetString("youCanRate"); } else if (purchaseResult.Status == ProductPurchaseStatus.NotPurchased) { dialog.Content = ResourceLoader.GetForCurrentView().GetString("anywayThanksForUsingApp") + "\n" + ResourceLoader.GetForCurrentView().GetString("youCanRate"); } else { dialog.Content = ResourceLoader.GetForCurrentView().GetString("errorOcurred") + "\n" + ResourceLoader.GetForCurrentView() .GetString("thanksAnywayTryAgainOrRate"); } } else { dialog.Content = ResourceLoader.GetForCurrentView().GetString("errorOcurredDonationPendingOrServerError") + "\n" + ResourceLoader.GetForCurrentView().GetString("thanksAnywayTryAgainOrRate"); } } else { dialog.Content = ResourceLoader.GetForCurrentView().GetString("noActiveDonations") + "\n" + ResourceLoader.GetForCurrentView().GetString("youCanRate"); } } catch { dialog.Content = ResourceLoader.GetForCurrentView().GetString("errorOcurred") + "\n" + ResourceLoader.GetForCurrentView().GetString("thanksAnywayTryAgainOrRate"); } await dialog.ShowAsync(); } }
public static async void Donate(string productId, bool isConsurable = false) { try { PopupMessage popupMessage = new PopupMessage(); if (NetworkInterface.GetIsNetworkAvailable()) { var listing = await CurrentApp.LoadListingInformationAsync(); var myProduct = listing.ProductListings.FirstOrDefault(p => p.Value.ProductId == productId); if (!CurrentApp.LicenseInformation.ProductLicenses[myProduct.Value.ProductId].IsActive) { await CurrentApp.RequestProductPurchaseAsync(productId, false); var productLicenses = CurrentApp.LicenseInformation.ProductLicenses; ProductLicense tokenLicense = productLicenses[productId]; if (tokenLicense.IsActive) { if (isConsurable)//если продукт расходуемый { CurrentApp.ReportProductFulfillment(productId); } var settings = IsolatedStorageSettings.ApplicationSettings; string product = "product" + productId; if (!settings.Contains(product)) { settings.Add(product, true); settings.Save(); } //popupMessage.Show("Thank you for your purchase!");//en //popupMessage.Show(AppResources.ThankYouForPurchase);//it popupMessage.Show("Thank you for your purchase!"); } } else { //popupMessage.Show("You have already bought this product!");//en //popupMessage.Show(AppResources.ProductExitsts);//it popupMessage.Show("You have already bought this product!"); } } else { //popupMessage.Show("Пожалуйста, проверьте подключение к сети Интернет!");//ru //popupMessage.Show("Please check the connection to the Internet!");//en //popupMessage.Show(AppResources.NoInternet);//it popupMessage.Show("Please check the connection to the Internet!"); } } catch (Exception ex) { } }
private async Task <List <Product> > RetrieveProductsAsync() { ListingInformation listing; LicenseInformation license; if (_useSimulator) { listing = await CurrentAppSimulator.LoadListingInformationAsync(); license = CurrentAppSimulator.LicenseInformation; } else { listing = await CurrentApp.LoadListingInformationAsync(); license = CurrentApp.LicenseInformation; } if (listing != null) { var products = listing.ProductListings; var results = new List <Product>(); foreach (var p in products.Values) { var product = new Product(); product.ProductID = p.ProductId; product.Name = p.Name; product.FormattedPrice = p.FormattedPrice; // Determine license status product.Purchased = license.ProductLicenses[product.ProductID].IsActive; if (product.Purchased) { product.Expires = license.ProductLicenses[product.ProductID].ExpirationDate.DateTime; } switch (p.ProductType) { case Windows.ApplicationModel.Store.ProductType.Consumable: product.Type = MarkerMetro.Unity.WinIntegration.Store.ProductType.Consumable; break; case Windows.ApplicationModel.Store.ProductType.Durable: product.Type = MarkerMetro.Unity.WinIntegration.Store.ProductType.Durable; break; } results.Add(product); } return(results); } return(null); }
async void GetRemoveAdButtonContent() { try { // 读取内购信息 var listing = await CurrentApp.LoadListingInformationAsync(); var iap = listing.ProductListings.FirstOrDefault(p => p.Value.ProductId == "RemoveAd"); RemoveAdButtonContent = $"【{iap.Value.Name} {iap.Value.FormattedPrice}】"; } catch (Exception) { } }
public async void BuyProductByName(Plan plan) { ListingInformation allProducts = await CurrentApp.LoadListingInformationAsync(); ProductListing productListing = null; if (!allProducts.ProductListings.TryGetValue(plan.Name, out productListing)) { _informerManagerLocator.InformerManager.AddMessage("Error", "Can't find this plan in market, sorry for this inconvenience"); PlanPurchased(this, new EventArgs(), null); } else { try { /********************************/ // DON'T DO THIS WITH TRUE APP var licensetest = CurrentApp.LicenseInformation.ProductLicenses[plan.Name]; if (licensetest.IsConsumable && licensetest.IsActive) { CurrentApp.ReportProductFulfillment(licensetest.ProductId); } /*******************************/ string result = await CurrentApp.RequestProductPurchaseAsync(productListing.ProductId, false); var license = CurrentApp.LicenseInformation.ProductLicenses[plan.Name]; if (license.IsConsumable && license.IsActive) { CurrentApp.ReportProductFulfillment(license.ProductId); //Pour envoyer un avis de reception chiffré /*string receiptXml = await CurrentApp.GetProductReceiptAsync(license.ProductId); * await SendReceipt(receiptXml);*/ } PlanPurchased(this, new EventArgs(), plan); } catch (Exception) { if (PlanPurchased != null) { PlanPurchased(this, new EventArgs(), null); } } } }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); LoadData(); DonationText = "Donate"; Task.Run(async() => { try { #if DEBUG var productLicense = CurrentAppSimulator.LicenseInformation.ProductLicenses[DonationProductId]; #else var productLicense = CurrentApp.LicenseInformation.ProductLicenses[DonationProductId]; #endif if (productLicense != null) { ApplicationData.Current.RoamingSettings.Values["HasDonated"] = productLicense.IsActive; HasDonated = productLicense.IsActive; } #if DEBUG var listingInformation = await CurrentAppSimulator.LoadListingInformationAsync(); #else var listingInformation = await CurrentApp.LoadListingInformationAsync(); #endif if (listingInformation != null) { var productListing = listingInformation.ProductListings[DonationProductId]; if (productListing != null) { await Execute.OnUIThread(() => { DonationAmount = productListing.FormattedPrice; DonationText = "Donate " + DonationAmount; }); } } } catch (Exception ex) { // Do Nothing Debug.WriteLine(ex.ToString()); } }); //AnimateHowToRepeat(); }
public async Task Init() { // Initialize the license info for use in the app that is uploaded to the Store. // Uncomment the following line in the release version of your app. //var licenseInformation = CurrentApp.LicenseInformation; // Initialize the license info for testing. // Comment the following line in the release version of your app. //var licenseInformation = CurrentAppSimulator.LicenseInformation; _listing = await CurrentApp.LoadListingInformationAsync(); //_listing = await CurrentApp.LoadListingInformationByProductIdsAsync(new string[] { "donate1"}); //var product1 = _listing.ProductListings.Count; }
public static IAsyncOperation <ListingInformation> LoadListingInformationAsync() { if (testmode == null) { throw new NotSupportedException(); } else if (testmode.Value) { return(CurrentAppSimulator.LoadListingInformationAsync()); } else { return(CurrentApp.LoadListingInformationAsync()); } }