void SubmitButton_Click(object sender, EventArgs e) { if (Page.IsValid) { try { bool testMode = CardNumberTextBox.Text == TEST_CC_NUMBER; OrderItemList<OrderItem> items = new OrderItemList<OrderItem>(); // you cant add the item if it already exists... foreach (OfferItem item in Controller.Offer.Items) { // Override Add for Duplicate Checks if (item.OfferItemType == OfferItemType.Standard || item.OfferItemType == OfferItemType.ForcedUpsell) { items.Add ( new OrderItem ( item.Sku, Controller.Customer.ID, testMode, Controller.LandingPage.ID, Controller.SessionID, item.ProductTypeID ) ); } } // Controller.Order.Save(); // save the order items to the database foreach (OrderItem item in items) { ICreditCard card = new CreditCard(); item.OrderSucceeded += new EventHandler(item_OrderSucceeded); item.OrderFailed += new EventHandler(item_OrderFailed); // new Products.Provider.ProductProcessor(item).Process(); if (item.Passed) { item.IsQueued = false; Controller.Order.Items.Add(item); } else { item.IsQueued = true; Controller.Queue.Items.Add(item); } /* * Lets say we are processing 3 items, 1 standard and 2 forced upsell * if the standard passes, and foced upsells fail, allow order * to continue processing..., but put failed orderitems in queue * * Lets say we are process 3 items, 1 standard and 2 forced.. * and standard fails... do not even attempt to process forced. * * Lets say there are 2 standard.. one failes and one passes * keep processing... and put one in queue */ } Controller.Order.Save(); // save the order items to the database Controller.Queue.Save(); // save the failed item queue to the database // OnOrderCreated(new OrderCreatedEventArgs(new Order(items), testMode)); } catch (WebException ex) { // indicative of a timeout or some sort of http error... OnOrderError(new OrderErrorEventArgs("Http Error", ex)); } catch (SqlException ex) { OnOrderError(new OrderErrorEventArgs("Sql Error", ex)); } catch (Exception ex) { // Log the error... LandingPageErrorEvent evnt = new LandingPageErrorEvent( ex.Message, "Unknown Error : " + ex.Message.ToString(), this, ex); evnt.Raise(); OnOrderError(new OrderErrorEventArgs("Unknown Error", ex)); } } }