private async void Page_Loaded(object sender, RoutedEventArgs e) { //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Remove these lines of code before publishing! // The actual CurrentApp will create a WindowsStoreProxy.xml // in the package's \LocalState\Microsoft\Windows Store\ApiData // folder where it stores the actual purchases. // Here we're just giving it a fake version of that file // for testing. StorageFolder proxyDataFolder = await Package.Current.InstalledLocation.GetFolderAsync("Assets"); StorageFile proxyFile = await proxyDataFolder.GetFileAsync("test.xml"); await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile); //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // You may want to put this at the App level AppLicenseInformation = CurrentAppSimulator.LicenseInformation; if (AppLicenseInformation.ProductLicenses["RemoveAdsOffer"].IsActive) { // Customer can access this feature. AdMediator_40F141.Visibility = Visibility.Collapsed; PurchaseButton.Visibility = Visibility.Collapsed; } else { // Customer can NOT access this feature. AdMediator_40F141.Visibility = Visibility.Visible; PurchaseButton.Visibility = Visibility.Visible; } }
public static async void LoadAddons() { StorageFolder proxyDataFolder = await Package.Current.InstalledLocation.GetFolderAsync("Assets"); StorageFile proxyFile = await proxyDataFolder.GetFileAsync("test.xml"); await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile); //TODO if (App.AppLicenseInformation.ProductLicenses[catsPackageToken].IsActive) { var collection = await CreateAddonCollectionAsync("Cats").ConfigureAwait(true); App.PurchaseCollections.Add(collection); } if (App.AppLicenseInformation.ProductLicenses[mountainsPackageToken].IsActive) { var collection = await CreateAddonCollectionAsync("Mountains").ConfigureAwait(true); App.PurchaseCollections.Add(collection); } if (App.AppLicenseInformation.ProductLicenses[spacePackageToken].IsActive) { var collection = await CreateAddonCollectionAsync("Space").ConfigureAwait(true); App.PurchaseCollections.Add(collection); } if (App.AppLicenseInformation.ProductLicenses[sunsetsPackageToken].IsActive) { var collection = await CreateAddonCollectionAsync("Sunsets").ConfigureAwait(true); App.PurchaseCollections.Add(collection); } }
private async void BuyButton_Click(object sender, RoutedEventArgs e) { var proxyFolder = await Package.Current.InstalledLocation.GetFolderAsync("Assets"); var proxyFile = await proxyFolder.GetFileAsync("WindowsStoreProxy.xml"); await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile); try { var listing = await CurrentAppSimulator.LoadListingInformationAsync(); var product = listing.ProductListings["product1"]; var results = await CurrentAppSimulator.RequestProductPurchaseAsync("product1"); if (results.Status == ProductPurchaseStatus.Succeeded) { VKAppPlatform.Instance.ReportInAppPurchase(new VKAppPlatform.InAppPurchaseData(results.ReceiptXml, product.FormattedPrice)); } } catch (Exception exc) { /* Handle exception */ } }
private async Task LoadInAppPurchaseProxyFileAsync() { StorageFolder proxyDataFolder = await Package.Current.InstalledLocation.GetFolderAsync("data"); StorageFile proxyFile = await proxyDataFolder.GetFileAsync("in-app-purchase.xml"); licenseChangeHandler = new LicenseChangedEventHandler(InAppPurchaseRefreshScenario); CurrentAppSimulator.LicenseInformation.LicenseChanged += licenseChangeHandler; await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile); // setup application upsell message try { ListingInformation listing = await CurrentAppSimulator.LoadListingInformationAsync(); var product1 = listing.ProductListings["product1"]; var product2 = listing.ProductListings["product2"]; Product1SellMessage.Text = "You can buy " + product1.Name + " for: " + product1.FormattedPrice + "."; Product2SellMessage.Text = "You can buy " + product2.Name + " for: " + product2.FormattedPrice + "."; } catch (Exception) { rootPage.NotifyUser("LoadListingInformationAsync API call failed", NotifyType.ErrorMessage); } }
private static async Task LoadConfigFile() { var storageFolder = Package.Current.InstalledLocation; var storageFileResult = await storageFolder.GetFileAsync(@"trial-mode.xml"); await CurrentAppSimulator.ReloadSimulatorAsync(storageFileResult); }
/// <summary> /// Initializes the <see cref="CurrentAppSimulator"/> with sample data. /// </summary> public static async void InitCurrentAppSimulator() { var proxyDataFolder = await Package.Current.InstalledLocation.GetFolderAsync(@"Store\Simulation"); var proxyFile = await proxyDataFolder.GetFileAsync("app-listing.xml"); await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile); }
public static async void ReloadSimulatorAsync() { StorageFolder installFolder = await Package.Current.InstalledLocation.GetFolderAsync("Assets"); StorageFile appSimulatorStorageFile = await installFolder.GetFileAsync("WindowsStoreProxy.xml"); await CurrentAppSimulator.ReloadSimulatorAsync(appSimulatorStorageFile); }
/// <summary> /// Загружает файл списка покупок. /// </summary> private async void LoadPurchaseFile() { var proxyDataFolder = await Package.Current.InstalledLocation.GetFolderAsync("Data"); var proxyFile = await proxyDataFolder.GetFileAsync("InAppPurchase.xml"); await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile); }
public static async void SimulatorInAppPurchasesInitialization() { StorageFolder proxyDataFolder = await Package.Current.InstalledLocation.GetFolderAsync("Resources"); StorageFile proxyFile = await proxyDataFolder.GetFileAsync("in-app-purchase.xml"); await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile); }
protected async override void OnNavigatedTo(NavigationEventArgs e) { StorageFolder f = await Package.Current.InstalledLocation.GetFolderAsync("Data"); StorageFile s = await f.GetFileAsync("WindowsStoreProxy.xml "); await CurrentAppSimulator.ReloadSimulatorAsync(s); }
private async Task LoadReceiptProxyFileAsync() { StorageFolder proxyDataFolder = await Package.Current.InstalledLocation.GetFolderAsync("data"); StorageFile proxyFile = await proxyDataFolder.GetFileAsync("receipt.xml"); licenseChangeHandler = new LicenseChangedEventHandler(ReceiptRefreshScenario); CurrentAppSimulator.LicenseInformation.LicenseChanged += licenseChangeHandler; await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile); }
public async void LicenseSimulator() { StorageFolder proxyDataFolder = await Package.Current.InstalledLocation.GetFolderAsync("Data"); StorageFile proxyFile = await proxyDataFolder.GetFileAsync("data.xml"); licenseChangeHandler = new LicenseChangedEventHandler(InAppPurchaseRefreshScenario); CurrentAppSimulator.LicenseInformation.LicenseChanged += licenseChangeHandler; await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile); }
public static async Task LoadFakeDataAsync(String fakeDataFilePath) { #if DEBUG var storageFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri(fakeDataFilePath, UriKind.Absolute)).AsTask().ConfigureAwait(false); await CurrentAppSimulator.ReloadSimulatorAsync(storageFile).AsTask().ConfigureAwait(false); #else await Task.FromResult <Object>(null); #endif }
private async Task LoadLicenseInfo() { //Lay thu muc Data trong ung dung (thu muc may chi doc) StorageFolder proxyDataFolder = await Package.Current.InstalledLocation.GetFolderAsync("Data"); //Doc thong tin trong tap tin CurrentAppSimulator StorageFile proxyFile = await proxyDataFolder.GetFileAsync("StoreLicense.xml"); //Nap du lieu vao CurrentAppSimulator await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile); }
/// <summary> /// Set your own Uri file to locate the new Uri("ms-appx:///Data/Data.data.xml) file. Put it on "if DEBUG Region". /// </summary> #if DEBUG public static async void LicenseSimulatorCustom(Uri uri) { try { var proxyFile = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(uri); licenseChangeHandler = new LicenseChangedEventHandler(InAppPurchaseRefreshScenario); CurrentAppSimulator.LicenseInformation.LicenseChanged += licenseChangeHandler; await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile); } catch { } }
public static async void SetTestMode(bool mode) { testmode = mode; if (mode) { var file = await Package.Current.InstalledLocation.GetFileAsync("WindowsStoreProxy.xml"); if (file != null) { await CurrentAppSimulator.ReloadSimulatorAsync(file); } } }
private async Task LocalLicenseServiceCtor() { try { var storeProxy = await ApplicationData.Current.LocalFolder.GetFileAsync("WindowsStoreProxy.xml"); await CurrentAppSimulator.ReloadSimulatorAsync(storeProxy); } catch { // ignored } _licenseInformation = CurrentAppSimulator.LicenseInformation; }
private async Task LoadInAppPurchaseProxyFileAsync() { try { StorageFolder proxyDataFolder = await Package.Current.InstalledLocation.GetFolderAsync("Data"); StorageFile proxyFile = await proxyDataFolder.GetFileAsync("WindowsStoreProxy.xml"); await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile); } catch (Exception e) { } }
private static async Task Initialize() { using (var releaser = await _InitializeLock.LockAsync()) { #if DEBUG var proxyFile = await StorageFile.GetFileFromApplicationUriAsync( new Uri("ms-appx:///Assets/StoreTesting.xml") ); await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile); #endif _Initialized = true; } }
private async Task LoadTrialModeProxyFileAsync() { StorageFolder proxyDataFolder = await Package.Current.InstalledLocation.GetFolderAsync("data"); StorageFile proxyFile = await proxyDataFolder.GetFileAsync("trial-mode.xml"); licenseChangeHandler = new LicenseChangedEventHandler(TrialModeRefreshScenario); CurrentAppSimulator.LicenseInformation.LicenseChanged += licenseChangeHandler; await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile); // setup application upsell message ListingInformation listing = await CurrentAppSimulator.LoadListingInformationAsync(); PurchasePrice.Text = "You can buy the full app for: " + listing.FormattedPrice + "."; }
/// <summary> /// Refreshes the simulator. /// </summary> /// <returns></returns> #pragma warning disable 1998 public async Task RefeshSimulator() { #if DEBUG var proxyPath = IOConstants.APPX_SCHEME + "/Assets/IAP/WindowsStoreProxy.xml"; var proxyFile = await _localStorageService.GetFileFromApplicationAsync(proxyPath); if (proxyFile != null) { await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile as StorageFile); } else { throw new FileNotFoundException("Could not find the proxy file under the path: " + proxyPath); } #endif }
public void BuildMockProducts(List <WinProductDescription> winProducts) { StorageFolder myfolder = ApplicationData.Current.LocalFolder; if (!Exists("WindowsStoreProxy.xml")) { myfolder.CreateFileAsync("WindowsStoreProxy.xml").AsTask().Wait(); } var file = myfolder.GetFileAsync("WindowsStoreProxy.xml").AsTask().Result; FileIO.WriteTextAsync(file, BuildDoc(winProducts).ToString()).AsTask().Wait(); var task = CurrentAppSimulator.ReloadSimulatorAsync(file).AsTask(); task.Wait(); }
private async Task LoadInAppPurchaseConsumablesProxyFileAsync() { StorageFolder proxyDataFolder = await Package.Current.InstalledLocation.GetFolderAsync("data"); StorageFile proxyFile = await proxyDataFolder.GetFileAsync("in-app-purchase-consumables-advanced.xml"); await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile); // setup application upsell message try { ListingInformation listing = await CurrentAppSimulator.LoadListingInformationAsync(); ProductListing product1 = listing.ProductListings["product1"]; Product1SellMessage.Text = "You can buy " + product1.Name + " for: " + product1.FormattedPrice + "."; ProductListing product2 = listing.ProductListings["product2"]; Product2SellMessage.Text = "You can buy " + product2.Name + " for: " + product2.FormattedPrice + "."; Log("", NotifyType.StatusMessage); } catch (Exception) { rootPage.NotifyUser("LoadListingInformationAsync API call failed", NotifyType.ErrorMessage); } // recover any unfulfilled consumables try { IReadOnlyList <UnfulfilledConsumable> products = await CurrentAppSimulator.GetUnfulfilledConsumablesAsync(); foreach (UnfulfilledConsumable product in products) { if (product.ProductId == "product1") { product1TempTransactionId = product.TransactionId; } else if (product.ProductId == "product2") { product2TempTransactionId = product.TransactionId; } } } catch (Exception) { rootPage.NotifyUser("GetUnfulfilledConsumablesAsync API call failed", NotifyType.ErrorMessage); } }
public async Task LoadLicenseData() { if (_loaded) { return; } var installedFolder = await Package.Current.InstalledLocation.GetFolderAsync("data"); var simulatorSettingsFile = await installedFolder.GetFileAsync("license.xml"); await CurrentAppSimulator.ReloadSimulatorAsync(simulatorSettingsFile); // TODO: Module 12: Exercise 2: Task 1.2: Store the license information _listingInformation = await CurrentAppSimulator.LoadListingInformationAsync(); _loaded = true; }
private static async Task LoadInAppPurchaseProxyFileAsync() { try { StorageFolder coreFolder = await Package.Current.InstalledLocation.GetFolderAsync("Core"); StorageFolder licenseFolder = await coreFolder.GetFolderAsync("License"); StorageFile proxyFile = await licenseFolder.GetFileAsync("WindowsStoreProxy.xml"); await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile); } catch (Exception e) { throw new Exception(e.Message, e.InnerException); } }
/// <summary> /// /// </summary> /// <param name="callback"></param> It is best not to set the callback parameter to null. The reason being you don't know /// when the license loading is finished. Best set it properly to avoid tricky race conditions /// <param name="licenseFilePath"></param> /// public static void LoadLicenseXMLFile(Action <CallbackResponse> callback, string licenseFilePath = null) { DebugLog.Log(LogLevel.Info, "entered LoadLicenseXmlFile"); Utils.RunOnWindowsUIThread(async() => { try { licenseFilePath = (licenseFilePath == null) ? "WindowsStoreProxy.xml" : licenseFilePath; StorageFile licenseFile; if (System.IO.Path.IsPathRooted(licenseFilePath)) { licenseFile = await StorageFile.GetFileFromPathAsync(licenseFilePath); } else { licenseFile = await Package.Current.InstalledLocation.GetFileAsync(licenseFilePath); } await CurrentAppSimulator.ReloadSimulatorAsync(licenseFile); // switch on the license simulation _isLicenseSimulationOn = true; if (callback != null) { Utils.RunOnUnityAppThread(() => { callback(new CallbackResponse { Exception = null, Status = CallbackStatus.Success }); }); } } catch (Exception ex) { DebugLog.Log(LogLevel.Fatal, "Error loading license file. License simulator will give incorrect results!" + ex.ToString()); callback(new CallbackResponse { Exception = ex, Status = CallbackStatus.Failure }); return; } }); }
public IAsyncOperation <bool> BuyAndFulfillCredits(string token) { return(AsyncInfo.Run(async cancellationToken => { try { #if DEBUG StorageFile proxyFile = await Package.Current.InstalledLocation.GetFileAsync("in-app-purchases-list.xml"); await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile); PurchaseResults purchaseResults = await CurrentAppSimulator.RequestProductPurchaseAsync("Credits"); #else PurchaseResults purchaseResults = await CurrentApp.RequestProductPurchaseAsync("Credits"); #endif switch (purchaseResults.Status) { case ProductPurchaseStatus.Succeeded: return await GrantFeatureInternal(purchaseResults, token) && await FulfillProductInternal(purchaseResults.TransactionId); case ProductPurchaseStatus.NotFulfilled: var result = true; if (!await IsGrantedInternal(purchaseResults.TransactionId, token)) { result = await GrantFeatureInternal(purchaseResults, token); } return result && await FulfillProductInternal(purchaseResults.TransactionId); case ProductPurchaseStatus.NotPurchased: return false; default: return false; } } catch (Exception) { return false; } })); }
private async Task LoadInAppPurchaseConsumablesProxyFileAsync() { StorageFolder proxyDataFolder = await Package.Current.InstalledLocation.GetFolderAsync("data"); StorageFile proxyFile = await proxyDataFolder.GetFileAsync("in-app-purchase-consumables.xml"); await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile); // setup application upsell message try { ListingInformation listing = await CurrentAppSimulator.LoadListingInformationAsync(); var product1 = listing.ProductListings["product1"]; Product1SellMessage.Text = "You can buy " + product1.Name + " for: " + product1.FormattedPrice + "."; Log("", NotifyType.StatusMessage); } catch (Exception) { rootPage.NotifyUser("LoadListingInformationAsync API call failed", NotifyType.ErrorMessage); } }
public static async Task <bool> SetupStoreServices() { try { #if DEBUG StorageFolder proxyDataFolder = await Package.Current.InstalledLocation.GetFolderAsync("Assets"); StorageFile proxyFile = await proxyDataFolder.GetFileAsync("test.xml"); await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile); LicenseInformation = CurrentAppSimulator.LicenseInformation; #else var context = StoreContext.GetDefault(); _appLicense = await context.GetAppLicenseAsync(); #endif return(true); } catch { return(false); } }
private async void InitialiseStore() { Helper.Purchases.getReference().Lock("pebble_notifications"); #if DEBUG try { StorageFile _resource = await StorageFile.GetFileFromApplicationUriAsync(new System.Uri("ms-appx:///Assets/WindowsStoreProxy.xml")); await CurrentAppSimulator.ReloadSimulatorAsync(_resource); var licenseInformation = CurrentAppSimulator.LicenseInformation; } catch (Exception e) { } Helper.Purchases.getReference().Unlock("pebble_notifications"); Helper.Purchases.getReference().Lock("pebble_sports"); Helper.Purchases.getReference().ClearTryAvailable("pebble_sports"); Helper.Purchases.getReference().Lock("pebble_tennis"); Helper.Purchases.getReference().ClearTryAvailable("pebble_tennis"); #endif }