Esempio n. 1
0
    protected void CheckoutButton_Click(object sender, EventArgs e)
    {
        TermsAndConditionsValidator.Validate();

        //Start processing only if, "Agree to terms and conditions" checkbox is checked.
        if (chkAgree.Checked)
        {
            // get the credit card...
            CreditCardInfo card = GetCreditCard();

            bool testMode = Page.User.IsInRole("Admin");

            try
            {
               Cathexis.Products.Provider.Product product = ProductController.GetProduct(this.Sku);

                //OrderItem item = new OrderItem(this.Sku, (Guid)Membership.GetUser().ProviderUserKey, card.Id, testMode, Globals.Settings.LandingPages.LandingPageID, Session.SessionID, product.TypeId);
               Cathexis.Entities.OrderItem item = new Cathexis.Entities.OrderItem(this.Sku, (Guid)Membership.GetUser().ProviderUserKey, card.Id, MembershipSettings.ConfigSettings.Website.Debug, Session.SessionID);

                ProductProcessor processor = new ProductProcessor(item);

                processor.OrderFailure += new OrderFailureEventHandler(processor_OrderFailure);
                processor.OrderSuccess += new OrderSuccessEventHandler(processor_OrderSuccess);

                processor.Process();

                // this needs to be replaced by some sort of concrete implementation
                // this would only work given that status=4 would compromise a successful completion of the order
                if (item.Status == 4)
                    processor.OnOrderSuccess(new OrderSuccessEventArgs(item));
                else
                    processor.OnOrderFailure(new OrderFailureEventArgs("unable to complete transaction"));
            }
            catch (OrderSaveException ex)
            {
                // raise a critical event...
                if (ex.InnerException != null)
                    this.ErrorMessage.Text = ex.InnerException.Message;
            }
        }
    }