/// <summary> /// Adds a verb to a Wallet item. When the user taps the verb, the application /// that owns this item will be launched with specific arguments so that /// it can perform the action /// </summary> /// <returns>An asynchronous action.</returns> public async Task AddVerbAsync() { if (walletItem == null) { rootPage.NotifyUser("Item does not exist. Add item using Scenario2", NotifyType.ErrorMessage); return; } try { // Add a verb to the wallet item. In this example, we are adding // a verb to allow the user to add funds to their account. walletItem.Verbs.Add("addfunds", new WalletVerb("Add Funds")); // Update the item in Wallet. await wallet.UpdateAsync(walletItem); rootPage.NotifyUser("Custom verb added.", NotifyType.StatusMessage); } catch (Exception ex) { string errorMessage = String.Format("Could not add custom verb. {0}", ex.Message); rootPage.NotifyUser(errorMessage, NotifyType.ErrorMessage); } }
/// <summary> /// Sets when this item is relevant. /// When an item is considered relevant, it will be promoted to the top spot in the Wallet summary view list /// and a toast notifcation will also be shown in a pop-up on the user's phone. /// </summary> /// <returns>An asynchronous action.</returns> public async Task AddRelevancyAsync() { if (walletItem == null) { rootPage.NotifyUser("Item does not exist. Add item using Scenario2", NotifyType.ErrorMessage); return; } try { // For this example, we will clear all relevancy data from the wallet item // to ensure that adding the item below does not fail because it already exists. walletItem.RelevantLocations.Clear(); // Create a new relevant location object. WalletRelevantLocation location = new WalletRelevantLocation(); location.DisplayMessage = "Welcome to Contoso Coffee on 5th"; // Set the desired location. var position = new Windows.Devices.Geolocation.BasicGeoposition(); position.Latitude = 47.63; position.Longitude = -122.2147; location.Position = position; // Add this location to the RelevantLocations collection on the item. // Note: The key for each entry must be unique in the collection. walletItem.RelevantLocations.Add("5thId", location); // Add a relevant date. walletItem.RelevantDate = DateTime.Now; walletItem.RelevantDateDisplayMessage = "Free coffee day"; // Update the item in Wallet. await wallet.UpdateAsync(walletItem); rootPage.NotifyUser("Relevancy data added. Open Wallet to see this card promoted to the top of the list because it is relevant (relevant date was defined as today).", NotifyType.StatusMessage); } catch (Exception ex) { string errorMessage = String.Format("Could not add relevancy data. {0}", ex.Message); rootPage.NotifyUser(errorMessage, NotifyType.ErrorMessage); } }
private async Task AddTransactionAsync() { if (walletItem == null) { rootPage.NotifyUser("Item does not exist. Add item using Scenario2", NotifyType.ErrorMessage); return; } try { // Create a transaction. WalletTransaction walletTransaction = new WalletTransaction(); walletTransaction.Description = "Double tall latte"; walletTransaction.DisplayAmount = "$3.27"; // The date and time of the transaction walletTransaction.TransactionDate = DateTime.Now; // Don't display the time of the transaction, just the date. walletTransaction.IgnoreTimeOfDay = false; // A string representing where the transaction took place. walletTransaction.DisplayLocation = "Contoso on 5th"; // Add the transaction to the TransactionHistory of this item. walletItem.TransactionHistory.Add("txnid123", walletTransaction); // Update the item in Wallet. await wallet.UpdateAsync(walletItem); rootPage.NotifyUser("Transaction added.", NotifyType.StatusMessage); } catch (Exception ex) { string errorMessage = String.Format("Could not add transaction. {0}", ex.Message); rootPage.NotifyUser(errorMessage, NotifyType.ErrorMessage); } }
private async void Update_Click(object sender, RoutedEventArgs e) { if (walletItem == null) { rootPage.NotifyUser("Item does not exist. Add item using Scenario2", NotifyType.ErrorMessage); return; } if (walletItem.DisplayProperties.ContainsKey("PointsId")) { // Update a property on the wallet item. walletItem.DisplayProperties["PointsId"].Value = CoffePointsValue.Text; // Update the item in the wallet. await wallet.UpdateAsync(walletItem); rootPage.NotifyUser("CoffeePoints has been updated in Wallet.", NotifyType.StatusMessage); } else { rootPage.NotifyUser("Item does not have a PointsId property.", NotifyType.ErrorMessage); return; } }