public async Task <string> BuyItem(DonateItemViewModel item) { try { var result = await _storeContext.RequestPurchaseAsync(item?.StoreId); switch (result.Status) { case StorePurchaseStatus.Succeeded: return(Localize.GetTranslateByKey(Localize.PurchaseStatusOk)); case StorePurchaseStatus.NotPurchased: return(String.Empty); default: return(Localize.GetTranslateByKey(Localize.PurchaseStatusBad)); } } catch { return(Localize.GetTranslateByKey(Localize.PurchaseStatusBad)); } }
public async Task InitializationAsyn() { if (_isLoaded) { return; } string[] productKinds = { "UnmanagedConsumable" }; var queryResult = await _storeContext.GetAssociatedStoreProductsAsync(productKinds); foreach (KeyValuePair <string, StoreProduct> item in queryResult.Products) { DonateItemViewModel donateItem = new DonateItemViewModel { Title = DonateUtility.GetValidurchaseName(item.Value.InAppOfferToken), StoreId = item.Key, Price = item.Value.Price.FormattedPrice }; Items.Add(donateItem); } _isLoaded = true; }