/// <summary> /// The refresh agent is run when a user taps refresh on an item in the wallet, or when it has been viewed enough for the agent to deem it refreshable. /// The sorts of things you might want to do here include: /// 1) Update the transaction history for the item /// 2) Update the logo, contact information, and other metadata for the item /// 3) Update the status message to inform the user of required actions or present them with useful information. /// </summary> /// <param name="args">The args contain the list of wallet items that are currently being refreshed. This way, if there are multiple services/items in the /// wallet, you'll know which ones the user is looking at, and hence which ones need to be updated.</param> protected override async void OnRefreshData(RefreshDataEventArgs args) { // Iterate through each wallet item that requires a refresh. foreach (WalletItem item in args.Items) { WalletTransactionItem card = item as WalletTransactionItem; if (card != null) { // In this example, we're performing a fake transaction worth 5 points each time the Wallet Agent runs. We are also displaying // 1 random deal from the mock web services deals as the status message with a deep link to the deal in the application itself. // In the wallet UI, you can force the referesh agent to run by opening an item, expanding the application menu (the "..." at the bottom right), // and choosing "refresh". int newBalance = MockWebService.WebService.PerformMockTransaction(card); card.DisplayAvailableBalance = newBalance + " points"; Coupon deal = MockWebService.WebService.GetRelevantDealForUser(); card.Message = "You might be interested in " + deal.Description + " Click here to check it out!"; card.MessageNavigationUri = new Uri("/CouponView.xaml?ID=" + deal.ID, UriKind.Relative); await card.SaveAsync(); } } NotifyComplete(); }
private void btnAddMembership_Click_1(object sender, RoutedEventArgs e) { try { WalletTransactionItem membershipItem; membershipItem = new WalletTransactionItem("Membership"); membershipItem.IssuerName = "TriangleBucks"; membershipItem.DisplayName = " TriangleBucks Membership Card"; membershipItem.IssuerPhone.Business = "987-654-321"; membershipItem.CustomerName = "Michael Crump"; membershipItem.AccountNumber = "103"; membershipItem.BillingPhone = "205-999-9999"; membershipItem.IssuerWebsite = new Uri("http://www.trianglebucks.com", UriKind.RelativeOrAbsolute); membershipItem.DisplayAvailableBalance = "1000 TrianglePoints"; ////Specify Logo Image BitmapImage bmp = new BitmapImage(); using (System.IO.Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Wallet_WP8.Assets.trianglebucks.bmp")) bmp.SetSource(stream); membershipItem.Logo99x99 = bmp; membershipItem.Logo159x159 = bmp; membershipItem.Logo336x336 = bmp; addWalletItemTask.Item = membershipItem; addWalletItemTask.Show(); } catch (Exception ex) { MessageBox.Show("There were the following errors when saving your membership to the wallet: " + ex.Message); } }
/// <summary> /// The refresh agent is run when a user taps refresh on an item in the wallet, or when it has been viewed enough for the agent to deem it refreshable. /// The sorts of things you might want to do here include: /// 1) Update the transaction history for the item /// 2) Update the logo, contact information, and other metadata for the item /// 3) Update the status message to inform the user of required actions or present them with useful information. /// </summary> /// <param name="args">The args contain the list of wallet items that are currently being refreshed. This way, if there are multiple services/items in the /// wallet, you'll know which ones the user is looking at, and hence which ones need to be updated.</param> /// </remarks> protected override async void OnRefreshData(RefreshDataEventArgs args) { Random rand = new Random(); foreach (WalletItem item in args.Items) { WalletTransactionItem card = item as WalletTransactionItem; if (card != null) { int i = rand.Next(5, 50); card.Message = i.ToString() + " TrianglePoints has been added!"; card.MessageNavigationUri = new Uri("/TriangleBucksDeal.xaml?Added=" + i.ToString(), UriKind.Relative); await card.SaveAsync(); } } foreach (WalletItem item in args.Items) { PaymentInstrument card = item as PaymentInstrument; if (card != null) { if (card.Id == "Credit") { card.Message = "New statement available"; card.MessageNavigationUri = new Uri("/AccountPage.xaml", UriKind.Relative); await card.SaveAsync(); } } } NotifyComplete(); }
/// <summary> /// Removes the membership card from wallet and refreshes UI. /// </summary> private void RemoveMembershipFromWallet(bool skipDialog) { MessageBoxResult mResult; if (skipDialog) { mResult = MessageBoxResult.OK; } else { mResult = MessageBox.Show("Are you sure you want to remove your membership card from the wallet?", "Membership Removal", MessageBoxButton.OKCancel); } if (mResult == MessageBoxResult.OK) { // Get the membership card in wallet WalletTransactionItem walletMembershipCard = LoadMembershipFromWallet(); // If the wallet membership card is not null, remove it. if (walletMembershipCard != null) { Wallet.Remove(walletMembershipCard); LoadMembership(); } } }
/// <summary> /// Uses AddWalletItemTask to add membership to the wallet. /// </summary> public void AddMembershipToWallet(Membership membership) { try { WalletTransactionItem membershipItem; membershipItem = new WalletTransactionItem("membership"); membershipItem.IssuerName = MockWebService.WebService.IssuerName; membershipItem.DisplayName = MockWebService.WebService.IssuerName + " Membership Card"; membershipItem.IssuerPhone.Business = MockWebService.WebService.IssuerPhone; membershipItem.CustomerName = membership.CustomerName; membershipItem.AccountNumber = membership.MembershipNumber; membershipItem.BillingPhone = membership.PhoneNumber; membershipItem.IssuerWebsite = new Uri(MockWebService.WebService.IssuerEmail); membershipItem.CustomProperties.Add("email", new CustomWalletProperty(membership.PhoneNumber)); membershipItem.DisplayAvailableBalance = "1000 points"; BitmapImage bmp = new BitmapImage(); using (System.IO.Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("sdkWalletMembershipDealsWP8CS.Assets.adventure.jpg")) bmp.SetSource(stream); membershipItem.Logo99x99 = bmp; membershipItem.Logo159x159 = bmp; membershipItem.Logo336x336 = bmp; addWalletItemTask.Item = membershipItem; addWalletItemTask.Show(); } catch (Exception ex) { MessageBox.Show("There were the following errors when saving your membership to the wallet: " + ex.Message); } }
/// <summary> /// Performs a fake transaction. If the card would be put at a negative balance, restores the balance to 1000. /// </summary> /// <param name="card">The card to perform the transaction on. The display balance is currently formatted as "1000 points"</param> /// <returns>The new balance.</returns> public int PerformMockTransaction(WalletTransactionItem card) { int newBalance; if (Int32.TryParse(card.DisplayAvailableBalance.Split()[0], out newBalance)) { newBalance -= 5; if (newBalance < 0) { newBalance = 1000; } } return(newBalance); }
/// <summary> /// This function determines if a membership exists in the webservice, if there exists a webservice membership, /// it checks if the associated wallettransactionitem is in the wallet. It then displays the correct UI. /// </summary> public void LoadMembership() { // Check webservice for membership webServiceMembership = MockWebService.WebService.GetMembership(); if (webServiceMembership != null) { // If we found a membership from web service // Show view membership panel. ViewMembershipPanel.Visibility = System.Windows.Visibility.Visible; GetMembershipPanel.Visibility = System.Windows.Visibility.Collapsed; // Make Data context the web service DataContext = webServiceMembership; // Check wallet for membership card WalletTransactionItem walletMembershipCard = LoadMembershipFromWallet(); if (walletMembershipCard != null) { // If we found a membership card in wallet // Show remove membership from wallet button RemoveFromWallet.Visibility = System.Windows.Visibility.Visible; SaveToWallet.Visibility = System.Windows.Visibility.Collapsed; } else { // If we didn't find membership card in wallet // Show save membership to wallet button RemoveFromWallet.Visibility = System.Windows.Visibility.Collapsed; SaveToWallet.Visibility = System.Windows.Visibility.Visible; } } else { // If we didn't find a membership in the web service. // Remove any existing wallet membership cards as we do not have an associated web service item RemoveMembershipFromWallet(true); // Show get a membership panel. ViewMembershipPanel.Visibility = System.Windows.Visibility.Collapsed; GetMembershipPanel.Visibility = System.Windows.Visibility.Visible; } }
private void transationbutton_Click(object sender, RoutedEventArgs e) { WalletTransactionItem walletTransactionItem = new WalletTransactionItem("walletTransactionItem1"); walletTransactionItem.DisplayName = "会员卡"; BitmapImage bitmapImage = new BitmapImage(); bitmapImage.SetSource(Application.GetResourceStream(new Uri("Assets/ApplicationIcon.png", UriKind.Relative)).Stream); walletTransactionItem.Logo159x159 = bitmapImage; walletTransactionItem.Logo336x336 = bitmapImage; walletTransactionItem.Logo99x99 = bitmapImage; AddWalletItemTask addWalletItemTask = new AddWalletItemTask(); addWalletItemTask.Item = walletTransactionItem; addWalletItemTask.Completed += addWalletItemTask_Completed; addWalletItemTask.Show(); }
private void CreateMembership_Click(object sender, RoutedEventArgs e) { var membershipItem = new WalletTransactionItem(App.MembershipWalletKey); membershipItem.IssuerName = "Fake Wein Club"; membershipItem.DisplayName = "Fake Wein Club"; membershipItem.CustomerName = string.Format("{0} {1}", FirstName.Text, LastName.Text); membershipItem.AccountNumber = GenerateMembershipNumber(); membershipItem.CustomProperties.Add(App.EmailWalletKey, new CustomWalletProperty(Email.Text)); membershipItem.CustomProperties.Add(App.PhoneWalletKey, new CustomWalletProperty(PhoneNumber.Text)); membershipItem.DisplayBalance = "50 Treuepunkte"; membershipItem.MemberSince = DateTime.Now; membershipItem.Message = "Ihre Mitglieds- und Treuekarte"; var logo336 = new BitmapImage(); using (Stream logoStream = Application.GetResourceStream(new Uri("Assets/Card336.jpg", UriKind.Relative)).Stream) { logo336.SetSource(logoStream); } var logo159 = new BitmapImage(); using (Stream logoStream = Application.GetResourceStream(new Uri("Assets/Card159.jpg", UriKind.Relative)).Stream) { logo159.SetSource(logoStream); } var logo99 = new BitmapImage(); using (Stream logoStream = Application.GetResourceStream(new Uri("Assets/Card99.jpg", UriKind.Relative)).Stream) { logo99.SetSource(logoStream); } membershipItem.Logo336x336 = logo336; membershipItem.Logo159x159 = logo159; membershipItem.Logo99x99 = logo99; _addWalletTask.Item = membershipItem; _addWalletTask.Show(); }
private void AddToWallet(Card card, bool showSuccessMessage = false) { if (card == null) return; var walletCard = new WalletTransactionItem(card.Id) { DisplayName = card.Name, IssuerName = card.CardProvider.ProviderName, Logo99x99 = GetTileFromProvider(card.CardProvider, 99), Logo159x159 = GetTileFromProvider(card.CardProvider, 159), Logo336x336 = GetTileFromProvider(card.CardProvider, 336), BarcodeImage = (BitmapSource) new Converters.BarcodeToImageConverter().Convert(card, typeof (BitmapSource), "false", null), NavigationUri = new Uri(string.Format("/Views/DisplayBarcodeView.xaml?id={0}", card.Id), UriKind.Relative), CustomerName = card.DisplayBarcode }; var walletTask = new AddWalletItemTask { Item = walletCard }; walletTask.Completed += (sender, result) => { if (result.Error != null) { App.ShowMessage("There was an error adding your card"); return; } CheckWalletForCard(card.Id); if (showSuccessMessage) App.ShowMessage("Card was added to the wallet"); }; walletTask.Show(); }
// Sample code for building a localized ApplicationBar //private void BuildLocalizedApplicationBar() //{ // // Set the page's ApplicationBar to a new instance of ApplicationBar. // ApplicationBar = new ApplicationBar(); // // Create a new button and set the text value to the localized string from AppResources. // ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png",UriKind.Relative)); // appBarButton.Text = AppResources.AppBarButtonText; // ApplicationBar.Buttons.Add(appBarButton); // // Create a new menu item with the localized string from AppResources. // ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText); // ApplicationBar.MenuItems.Add(appBarMenuItem); //} #region Membership private void AddMembershipButtonQR_Click(object sender, RoutedEventArgs e) { //string itemId = string.IsNullOrEmpty(walletItemName.Text) ? walletItemName.Text : cardName; WalletTransactionItem card = new WalletTransactionItem(); card.Nickname = membershipCardQRName; // Set colors, to give the card our distinct branding. card.BackgroundColor = System.Windows.Media.Colors.Brown; var bmp = new BitmapImage(new Uri("/Assets/icons/CaffeLuzzoMedium.png", UriKind.RelativeOrAbsolute)); bmp.CreateOptions = BitmapCreateOptions.None; card.Logo336x336 = bmp; bmp = new BitmapImage(new Uri("/Assets/icons/CaffeLuzzoSmall.png", UriKind.RelativeOrAbsolute)); bmp.CreateOptions = BitmapCreateOptions.None; card.Logo159x159 = bmp; bmp = new BitmapImage(new Uri("/Assets/icons/CaffeLuzzoIcon.png", UriKind.RelativeOrAbsolute)); bmp.CreateOptions = BitmapCreateOptions.None; card.Logo99x99 = bmp; //card.UserImage = new BitmapImage(new Uri("/Assets/icons/CaffeLuzzoIcon.png", UriKind.Relative)); card.DisplayName = membershipCardQRName; // Add the customer account number. CustomWalletProperty prop = new CustomWalletProperty ("HOLD", "HOLD"); card.CustomProperties["Holder1"] = prop; prop = new CustomWalletProperty ("HOLD", "HOLD"); card.CustomProperties["Holder2"] = prop; // Add the customer account number. prop = new CustomWalletProperty ("Caffe Luzzo", "Membership Card"); card.CustomProperties["Title"] = prop; card.IssuerName = "Caffe Luzzo"; prop = new CustomWalletProperty("Website", "http://www.caffelusso.com/#!"); card.CustomProperties["Website"] = prop; card.IssuerWebsite = new Uri("http://www.caffelusso.us"); prop = new CustomWalletProperty ("Address", "17725 Ne 65th St Ste A150, Redmond, WA 98052 "); card.CustomProperties["Address"] = prop; card.IssuerAddress.Business1.AssignCivicAddress(new CivicAddress() { AddressLine1 = "17725 Ne 65th St Ste A150", City = "Redmond", StateProvince = "WA", PostalCode = "98052" }); prop = new CustomWalletProperty ("Rewards", "99"); card.CustomProperties["Points"] = prop; card.DisplayAvailableBalance = "100"; // Add the customer account number. prop = new CustomWalletProperty ("Account Number", "12345678"); // We don't want this field entity extracted as it will be interpreted as a phone number. card.CustomProperties["AcctId"] = prop; card.AccountNumber = "12345678"; // Encode the user's account number as a Qr Code to be used in the store. //card.Barcode = new WalletBarcode(WalletBarcodeSymbology.Qr, "12345678"); // Add a promotional message to the card. card.Message = "Tap here for your 15% off coupon"; ((Button)sender).IsEnabled = false; this.MembershipInfoButtonQR.IsEnabled = true; task.Item = card; task.Show(); }
private void AddMembershipButtonBarcode_Click(object sender, RoutedEventArgs e) { WalletTransactionItem card = new WalletTransactionItem(); card.Nickname = membershipCardBarcodeName; // Set colors, to give the card our distinct branding. card.BackgroundColor = System.Windows.Media.Colors.Brown; card.Logo336x336 = new BitmapImage(new Uri("/Assets/icons/bellavita_cafe_Medium.png", UriKind.RelativeOrAbsolute)); card.Logo159x159 = new BitmapImage(new Uri("/Assets/icons/bellavita_cafe_Small.png", UriKind.RelativeOrAbsolute)); card.Logo99x99 = new BitmapImage(new Uri("/Assets/icons/bellavita_cafe_Icon.png", UriKind.RelativeOrAbsolute)); //card.UserImage = new BitmapImage(new Uri("Assets/icons/bellavita_cafe_Icon.png", UriKind.Relative)); card.DisplayName= membershipCardBarcodeName; // Add the customer account number. CustomWalletProperty prop = new CustomWalletProperty ("HOLD", "HOLD"); card.CustomProperties["Holder1"] = prop; prop = new CustomWalletProperty ("HOLD", "HOLD"); card.CustomProperties["Holder2"] = prop; // Add the customer account number. prop = new CustomWalletProperty ("Cafe Bella", "Membership Card"); //prop.DetailViewPosition = WalletDetailViewPosition.PrimaryField1; // We don't want this field entity extracted as it will be interpreted as a phone number. card.CustomProperties["Title"] = prop; card.IssuerName = "Cafe Bella"; prop = new CustomWalletProperty ("Website", "http://www.lavitaebella.us/"); //prop.DetailViewPosition = WalletDetailViewPosition.PrimaryField2; card.CustomProperties["Website"] = prop; card.IssuerWebsite = new Uri("http://www.lavitaebella.us"); prop = new CustomWalletProperty ("Address", "2411 2nd Ave, Seattle, WA 98121"); card.CustomProperties["Address"] = prop; card.IssuerAddress.Business1.AssignCivicAddress(new CivicAddress() { AddressLine1 = "2411 2nd Ave", City = "Seattle", StateProvince = "WA", PostalCode = "98121" }); prop = new CustomWalletProperty ("Rewards", "100"); card.CustomProperties["Points"] = prop; card.DisplayAvailableBalance = "100"; // Add the customer account number. prop = new CustomWalletProperty ("Account Number", "987654321"); card.CustomProperties["AcctId"] = prop; card.AccountNumber = "987654321"; // Encode the user's account number as a Qr Code to be used in the store. //card.BarcodeImage = new Barcode // new WalletBarcode(WalletBarcodeSymbology.Ean13, "9876543210123"); // Add a promotional message to the card. card.Message = "Tap here for your 15% off coupon"; //card.IsDisplayMessageLaunchable = true; ((Button)sender).IsEnabled = false; this.MembershipInfoButtonBarcode.IsEnabled = true; task.Item = card; task.Show(); }