Beispiel #1
0
        public bool ProcessOrder(Guid userID, Guid cardID, string sku, bool isTest, string sessionID)
        {
            Product product = ProductController.GetProduct(sku);
           
            // create order item...
            OrderItem item = new OrderItem(sku, userID, cardID, isTest, sessionID);

            ProductProcessor processor = new ProductProcessor(item);

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

            ProductType prodType = ProductController.GetProductType(product.TypeId);

            return
                ProductController.Providers[prodType.ProviderName].PassedStatus <= processor.Order.Status;

        }
    protected void CreateEnrollmentDialog_OkButtonClicked(object sender, EventArgs e)
    {
        EnrollmentValidator.Validate();
        Guid cardId;
        Guid userId;
        string sku;

        if (base.Page.IsValid)
        {
            if (!string.IsNullOrEmpty(CreditCardDropdown.SelectedValue.ToString()))
                cardId = new Guid(CreditCardDropdown.SelectedValue.ToString());
            else
                cardId = new Guid();

            //userId = (Guid)Membership.GetUser().ProviderUserKey;
            userId = (Guid)Membership.GetUser(UserName).ProviderUserKey;
            sku = SKUDropDownList.SelectedValue.ToString();

            if (!chkFree.Checked)
            {
                try
                {
                    OrderItem item = new OrderItem(sku, userId, false, Guid.NewGuid(), Session.SessionID, Guid.NewGuid());
                    ProductProcessor processor = new ProductProcessor(item);
                    processor.Process();
                }
                catch (Exception ex)
                {
                    // Create the event
                    CriticalTransactionEvent transactionException = new CriticalTransactionEvent(
                                  "Error in the Transaction!!",
                                  this,
                                  System.Web.Management.WebEventCodes.WebExtendedBase + 1230251,
                                  ex);

                    // Raise the event
                    transactionException.Raise();
                }
            }
            else
            {
                ClassroomController.InsertEnrollment(userId, sku);
            }
            OnEnrollmentCreated(e);
            CreateEnrollmentDialog.Reset();
            BindDialog();
            DataBind();
        }
        else
        {

            ValidationHelper.SetFocusToFirstError(this.Page, "create_enrollment");
        }
    }
Beispiel #3
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;
            }
        }
    }