private async void TryNow_Click(object sender, RoutedEventArgs e) { // Create a BuyNow object with your PayPal // merchant account emailid. Remember to onboard // your merchant account by granting third party // permissions as detailed in the docs BuyNow bn = new BuyNow("*****@*****.**"); bn.UseSandbox = true; // Add items to the purchase foreach (MenuItem s in this.MenuControl.SelectedItems) { ItemBuilder builder = new ItemBuilder(s.Name) .Description(s.Name) .ID(s.ItemId) .Price(s.Price); bn.AddItem(builder); } // Attach event handlers. The BuyNow class emits 5 events // start, auth, error, cancel and complete bn.Start += new EventHandler <PayPal.Checkout.Event.StartEventArgs>((source, args) => { this.Status.Message.Text = "Initiating payment"; }); bn.Auth += new EventHandler <PayPal.Checkout.Event.AuthEventArgs>((source, args) => { this.Status.Message.Text = "Authenticating payment: " + args.Token; }); bn.Complete += new EventHandler <PayPal.Checkout.Event.CompleteEventArgs>((source, args) => { this.Status.displayStoryboard.Begin(); this.Status.Message.Text = "Your payment is complete. Transaction id: " + args.TransactionID; clearSelection(); }); bn.Cancel += new EventHandler <PayPal.Checkout.Event.CancelEventArgs>((source, args) => { this.Status.displayStoryboard.Begin(); this.Status.Message.Text = "Your payment was cancelled."; clearSelection(); }); bn.Error += new EventHandler <PayPal.Checkout.Event.ErrorEventArgs>((source, args) => { this.Status.displayStoryboard.Begin(); this.Status.Message.Text = "There was an error processing your payment: " + args.Type + " " + args.Message; clearSelection(); }); // Ready to go. Call the asynchronous Execute operation // to initiate the payment. Remember to mark your calling // function with the async keyword since this is an async call bool ret = await bn.Execute(); }
private async void TryNow_Click(object sender, RoutedEventArgs e) { // Create a BuyNow object with your PayPal // merchant account emailid. Remember to onboard // your merchant account by granting third party // permissions as detailed in the docs BuyNow bn = new BuyNow("*****@*****.**"); bn.UseSandbox = true; // Add items to the purchase foreach (MenuItem s in this.MenuControl.SelectedItems) { ItemBuilder builder = new ItemBuilder(s.Name) .Description(s.Name) .ID(s.ItemId) .Price(s.Price); bn.AddItem(builder); } // Attach event handlers. The BuyNow class emits 5 events // start, auth, error, cancel and complete bn.Start += new EventHandler<PayPal.Checkout.Event.StartEventArgs>((source, args) => { this.Status.Message.Text = "Initiating payment"; }); bn.Auth += new EventHandler<PayPal.Checkout.Event.AuthEventArgs>((source, args) => { this.Status.Message.Text = "Authenticating payment: " + args.Token; }); bn.Complete += new EventHandler<PayPal.Checkout.Event.CompleteEventArgs>((source, args) => { this.Status.displayStoryboard.Begin(); this.Status.Message.Text = "Your payment is complete. Transaction id: " + args.TransactionID; clearSelection(); }); bn.Cancel += new EventHandler<PayPal.Checkout.Event.CancelEventArgs>((source, args) => { this.Status.displayStoryboard.Begin(); this.Status.Message.Text = "Your payment was cancelled."; clearSelection(); }); bn.Error += new EventHandler<PayPal.Checkout.Event.ErrorEventArgs>((source, args) => { this.Status.displayStoryboard.Begin(); this.Status.Message.Text = "There was an error processing your payment: " + args.Type + " " + args.Message; clearSelection(); }); // Ready to go. Call the asynchronous Execute operation // to initiate the payment. Remember to mark your calling // function with the async keyword since this is an async call bool ret = await bn.Execute(); }
private void AddToCartButton_Click(object sender, EventArgs e) { if (AddToCartButton.Text == "Add to Cart") { if (Game[1].Checked || Game[2].Checked || Game[3].Checked) { AddToCart(); } else if (!(Game[1].Checked && Game[2].Checked && Game[3].Checked)) { MessageBox.Show("You need to pick a game", "Try Again", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); Game1.Focus(); } } else if (AddToCartButton.Text == "Apply") { foreach (CheckBox CheckBox in Game.Values) { if (CheckBox.Checked) { DiscountCalculation(); } } DiscountInsert.Text = $"{discount:C}"; TotalCalculation(); TotalInsert.Text = $"{total:C}"; AddToCartButton.Enabled = false; PromoCodeText1.Enabled = false; PromoCodeText2.Enabled = false; foreach (ComboBox ComboBox in SubscriptionChoicesForGame.Values) { ComboBox.SelectionLength = 0; } BuyNow.Focus(); } }
private void AddToCart() { List <string> game = new List <string>(); for (int i = 0; i <= SubscriptionChoicesForGame.Count() + 1; i++) { game.Add(null); } for (int i = 1; i <= Game.Count; i++) { ChoiceMadeFor(Game[i], Game_Selection[i], SubscriptionChoicesForGame[i]); } Size = MaximumSize; foreach (CheckBox CheckBox in Game.Values) { CheckBox.Enabled = false; } foreach (Control Ctrl in Controls) { if (Ctrl is GroupBox) { (Ctrl as GroupBox).Size = Ctrl.MinimumSize; } if (Ctrl is Button) { (Ctrl as Button).Visible = true; } } foreach (ComboBox ComboBox in SubscriptionChoicesForGame.Values) { ComboBox.Size = ComboBox.MinimumSize; ComboBox.Enabled = false; ComboBox.SelectionLength = 0; } foreach (Control Ctrl in PromoCodeGrouping.Controls) { if (Ctrl is TextBox) { if (Ctrl.Name == PromoCodeText2.Name) { (Ctrl as TextBox).Focus(); } } } for (int i = 1; i <= Game.Count; i++) { CheckOutReceiptApplying(game[i], Game_Selection[i]); } AddToCartButton.Text = "Apply"; if (ValidPromoCode(PromoCodeText2.Text, out string errMsg)) { AddToCartButton.Enabled = false; PromoCodeText1.Enabled = false; PromoCodeText2.Enabled = false; BuyNow.Focus(); } }
public void PerformOperation() { objRest = new RESTHandler(@"https://extraction.import.io/query/extractor/cc2ec580-d520-44e4-9bd6-0048f8c2f663?_apikey=a759e60c74034f7f839fefaf97502e5a6bc346bf84931f5c90d436954961631a25086cb8866a99ae3dd9f2cf60d7ee0e7586aa58a38c227f1b7eede0b17e03d17c511383803d0abbb81d0d1587392d6a&url=http%3A%2F%2Fwww.trademe.co.nz%2FBrowse%2FSearchResults.aspx%3Fsort_order%3Dbids_asc%26from%3Dadvanced%26advanced%3Dtrue%26searchstring%3D2004%26current%3D0%26cid%3D268%26rptpath%3D1-268-%26searchregion%3D100"); myResponse = objRest.ExecuteCurrentRequest(); //Check if group is null if (myResponse.extractorData.data[0].group != null) { //populate groupList with all groups. groupList = myResponse.extractorData.data[0].group; } List <VehicleListing> Vehicles = new List <VehicleListing>(); //Loop through all groups. for (int i = 0; i < groupList.Count; i++) { //Description operation. if (myResponse.extractorData.data[0].group[i].Description != null) { Description = myResponse.extractorData.data[0].group[i].Description[0].text; string[] myDescriptions = Description.Split(' '); yearDescription = myDescriptions[(myDescriptions.Count() - 1)]; modelDescription = myDescriptions[0]; Description = ""; for (int x = 1; x < (myDescriptions.Count() - 1); x++) { Description = Description + " " + myDescriptions[x]; } } //BuyNow operation. if (myResponse.extractorData.data[0].group[i].BuyNow != null) { BuyNow = myResponse.extractorData.data[0].group[i].BuyNow[0].text; string[] BuyNowDollars = BuyNow.Split(' '); BuyNow = BuyNowDollars[0]; BuyNow = CleansePrice(BuyNow); } //Price operation. if (myResponse.extractorData.data[0].group[i].Price != null) { Price = myResponse.extractorData.data[0].group[i].Price[0].text; Price = CleansePrice(Price); } //BidCount operation. if (myResponse.extractorData.data[0].group[i].BidCount != null) { BidCount = myResponse.extractorData.data[0].group[i].BidCount[0].text; string[] BidNumbers = BidCount.Split(null); BidCount = BidNumbers[0]; } //Dealer operation. if (myResponse.extractorData.data[0].group[i].Dealer != null) { string myDealer = myResponse.extractorData.data[0].group[i].Dealer[0].alt; if (myDealer == "Dealer listing") { Dealer = "1"; } } else { Dealer = "0"; } //Flags operation. if (myResponse.extractorData.data[0].group[i].Flags != null) { string myFlags = myResponse.extractorData.data[0].group[i].Flags[0].alt; if (myFlags == "Reserve Met") { Flags = "1"; } else if (myFlags == "No Reserve") { Flags = "0"; } } //Perform details operation if (myResponse.extractorData.data[0].group[i].Details != null) { detailList = myResponse.extractorData.data[0].group[i].Details; Details = ""; mainDetails = myResponse.extractorData.data[0].group[i].Details[0].text; String[] mainTempArray = mainDetails.Split(','); Body = mainTempArray[2]; Odometer = mainTempArray[0] + mainTempArray[1]; Odometer = RemoveTail(Odometer); Engine = mainTempArray[3]; Transmission = mainTempArray[4]; //clean Engine //MessageBox.Show(Engine); String[] engineArray = Engine.Split(' '); Engine = engineArray[1]; Engine = RemoveTail(Engine); EngineType = engineArray[2] + ' ' + engineArray[3]; //clean second detail tempDetail = myResponse.extractorData.data[0].group[i].Details[1].text; String[] tempArray = tempDetail.Split(','); cityDetail = tempArray[0]; } Vehicles.Add(new VehicleListing() { VehicleModel = modelDescription, VehicleDescription = Description, VehicleYear = yearDescription, VehicleBuyNow = BuyNow, VehiclePrice = Price, VehicleBody = Body, VehicleOdometer = Odometer, VehicleEngineSize = Engine, VehicleEngineType = EngineType, VehicleTransmission = Transmission, VehicleBidCount = BidCount, VehicleDealer = Dealer, VehicleFlags = Flags, /*VehicleDetails = mainDetails,*/ VehicleCity = cityDetail }); } dataGrid.ItemsSource = Vehicles; }
private async void puchaseButtonClick(object sender, RoutedEventArgs e) { buyNow = new BuyNow("*****@*****.**"); buyNow.UseSandbox = true; // Set the currency to use US Dollars buyNow.Currency = "USD"; // Use the ItemBuilder to create a new example item PayPal.Checkout.ItemBuilder itemBuilder = new PayPal.Checkout.ItemBuilder("Example Item") .ID(item.Id) .Price(item.Price) .Description(item.Description) .Quantity(item.Quantity); // Add the item to the purchase, buyNow.AddItem(itemBuilder.Build()); // Attach event handlers so you will be notified of important events // The BuyNow interface provides 5 events - Start, Auth, Cancel, Complete and Error // See http://paypal.github.io/Windows8SDK/csharp.html#Events for more buyNow.Error += new EventHandler<PayPal.Checkout.Event.ErrorEventArgs>((source, eventArg) => { this.tbBarcodeType.Text = "There was an error processing your payment: " + eventArg.Message; }); buyNow.Complete += new EventHandler<PayPal.Checkout.Event.CompleteEventArgs>((source, eventArg) => { this.tbBarcodeType.Text = "Payment is complete. Transaction id: " + eventArg.TransactionID; }); buyNow.Cancel += new EventHandler<PayPal.Checkout.Event.CancelEventArgs>((source, eventArg) => { this.tbBarcodeType.Text = "Payment was canceled by the user."; }); // Launch the secure PayPal interface. This is an asynchronous method await buyNow.Execute(); }