Beispiel #1
0
        public void Process()
        {
            // configure processor

            _product = ProductController.GetProduct(Order.Sku);
            _productType = ProductController.GetProductType(_product.TypeId);
            ContinueNow = true;

            // log start of execution
            // CreateAudit("Order Processor Started");

            // process section
            try
            {
                while (ContinueNow)
                {
                    ContinueNow = false;
                    GetCurrentSection();
                    CurrentSection.Process(this);
                }
            }
            catch (Exception ex)
            {
                // error logging goes here...
                throw ex;
            }

            // log end of execution
            // CreateAudit("Order Processor Finished");
        }
Beispiel #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        OddClasses.ItemDataBound += new RepeaterItemEventHandler(Classes_ItemDataBound);
        EvenClasses.ItemDataBound += new RepeaterItemEventHandler(Classes_ItemDataBound);

        _data = ClassroomController.GetUserClassData(this.CourseSKU, this.UserID);
        _product = Monaco.Classroom.Ordering.ProductController.GetProduct(this.CourseSKU);

        if (!IsPostBack)
            DataBind();
    }
        public void Process(Monaco.Classroom.Ordering.ProductProcessor processor)
        {
            try
            {
                //Cathexis.Entities.OrderItem orderItem = processor.Order;
                Monaco.Billing.Entities.OrderItem orderItem = processor.Order;  
              //  Product product = ProductController.GetProduct(orderItem.Sku);
                Product product = new Product();
                SubscriptionInfo sub = new SubscriptionInfo();
                sub.Id = Guid.NewGuid();
                sub.UserId = orderItem.CustomerID;
                sub.CreateDate = DateTime.Now;
                sub.StartDate = DateTime.Now.AddDays(product.TrialPeriodDays) ;
                sub.Status = BillingStatus.Active;
                sub.GatewayId = product.GatewayId;
                sub.CreditCardId = orderItem.CreditCardId;
                sub.RefId = orderItem.ID;


                sub.IntervalType = IntervalType.Month;
                sub.IntervalLength = 1;
                if (product.AvailableDuration.HasValue)
                    sub.TotalOccurrences = (int)product.AvailableDuration;
                else
                    sub.TotalOccurrences = int.MaxValue;

                sub.TrialOccurrences = 0;
                sub.TotalOccurrencesDone = 0;
                sub.TrialOccurrencesDone = 0;
                sub.TrialAmount = 0;
                sub.Amount = (decimal)product.RecurringPrice;

                if (product.RecurringPrice > 0)
                {
                    BillingController.CreateSubscription(ref sub);
                }
               
                processor.Order.UpdateStatus(processor.Order.Status + 1);
               
            }
            catch (Exception)
            {
                // exception was caught, but at this point card was charged initially, 
                // so we can recreate this later

                processor.OnOrderFailure(new OrderFailureEventArgs("Unable to create subscription"));
               
            }
            processor.ContinueNow = false;

             
        }
        public void Process(Monaco.Classroom.Ordering.ProductProcessor processor)
        {
            processor.ContinueNow = false;
            Cathexis.Entities.OrderItem orderItem = new Cathexis.Entities.OrderItem();//= processor.Order;
          //  Product product = ProductController.GetProduct(orderItem.Sku);
            Product product = new Product ();
            double amountToAuthorize = product.InitialPrice;
            GatewayInfo gateway = BillingController.GetGateway(product.GatewayId);
         
            Guid g = new Guid ("FEF56DBF-86D3-428C-926C-00145AF288C5");
            CreditCardInfo card = BillingController.GetCreditCard(g);
            GatewayTypeInfo gatewayType = BillingController.GetGatewayType(gateway.GatewayTypeId);
            Customer customer = BillingController.GetCustomer(orderItem.CustomerID);

            if (amountToAuthorize > 0)
            {
                TransactionInfo transaction = BillingController.ProcessPayment(gateway, gatewayType, orderItem.ID, customer, card, (decimal)amountToAuthorize, orderItem.TestMode);

                if (transaction.Status != TransactionStatus.Approved)
                {
                    // delete the enrollment...
                    // todo: implement logic to delete enrollment
                    

                    processor.OnOrderFailure(new OrderFailureEventArgs("Credit Card Was Declined"));
                    processor.ContinueNow = false;
                }
                else
                {
                    processor.Order.UpdateStatus(processor.Order.Status + 1);
                    processor.ContinueNow = true;
                }
            }
            else
            {
                processor.Order.UpdateStatus(processor.Order.Status + 1);
                processor.ContinueNow = true;
            }
        }
Beispiel #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
         
        rptCategoryLinks.ItemDataBound += new RepeaterItemEventHandler(rptCategoryLinks_ItemDataBound);
        _product = ProductController.GetProduct(this.Sku);

        rptCourses.ItemDataBound += new RepeaterItemEventHandler(rptCourses_ItemDataBound);

        //RegValidator.ValidationExpression = Monaco.Common.RegularExpressions.ValidCreditCard;

        if (!IsPostBack)
        {
            if (Request.IsAuthenticated)
            {
                if (ClassroomController.IsUserEnrolledForCourse(this.UserID, this._product.RefId))
                {
                    CheckOutPlaceHolder.Controls.Clear();
                    CheckOutPlaceHolder.Controls.Add(Page.LoadControl("Controls/CourseNotAvailable.ascx"));
                }
                else
                {

                    DataBind();
                }
            }
            else
            {
                DataBind();
            }

        }
        BindClassEntityInfo();
       
    }
    private void BindDialog()
    {
        _entity = Monaco.Classroom.Ordering.ProductController.GetProduct(this.SKU);

    }
        public static void UpdateProduct(Product entity)
        {
            DbCommand cmd = SqlHelpers.CreateCommand(ConnectionString);
            cmd.CommandText = "bill_PRODUCT_Update";

            cmd.AddInputParam("@SKU", DbType.AnsiString, entity.Sku);
            cmd.AddInputParam("@GatewayId", DbType.Guid, entity.GatewayId);
            cmd.AddInputParam("@TrialPeriodDays", DbType.Int32, entity.TrialPeriodDays);
            cmd.AddInputParam("@InitialPrice", DbType.Decimal, entity.InitialPrice);
            cmd.AddInputParam("@RecurringPrice", DbType.Decimal, entity.RecurringPrice);
            cmd.AddInputParam("@SubscriptionDuration", DbType.Int32, entity.SubscriptionDuration);
            cmd.AddInputParam("@AvailableDuration", DbType.Int32, entity.AvailableDuration);
            cmd.AddInputParam("@LastUpdatedBy", DbType.AnsiString, entity.LastUpdatedBy);
            cmd.AddInputParam("@RefId", DbType.Int32, entity.RefId);
            cmd.AddInputParam("@Current", DbType.Boolean, entity.IsCurrent);
            cmd.AddInputParam("@Active", DbType.Boolean, entity.Active);
            SqlHelpers.ExecuteNonQuery(cmd);
      }
    protected void CreatePaymentOptionDialog_OkButtonClicked(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            if (this.CourseId > 0)
            {

                Monaco.Classroom.Ordering.Product entity = new Monaco.Classroom.Ordering.Product();
                entity.GatewayId = new Guid(ddlGateway.SelectedValue) ;
     
                entity.RefId = this.CourseId;
                entity.Sku = SKUTextBox.Text;
                entity.TrialPeriodDays = Convert.ToInt32(TrialPeriodDaysTextBox.Text);
                entity.InitialPrice = Convert.ToDouble(InitialPriceTextBox.Text);
                entity.RecurringPrice = Convert.ToDouble(RecurringPriceTextBox.Text);

                int subscriptionDuration = 0;
                if (int.TryParse(SubscriptionDurationTextBox.Text, out subscriptionDuration))
                    entity.SubscriptionDuration = subscriptionDuration;

                int availabilityDuration = 0;
                if (int.TryParse(AvailableDurationTextBox.Text, out availabilityDuration))
                    entity.AvailableDuration = availabilityDuration;

                if (chkInfiniteDuration.Checked)
                    entity.SubscriptionDuration = null;

                if (chkInfiniteAvailability.Checked)
                    entity.AvailableDuration = null;

                entity.CreatedBy = this.Page.User.Identity.Name;
                entity.LastUpdatedBy = this.Page.User.Identity.Name;
                entity.CreatedOn = DateTime.Now;
                entity.LastUpdatedOn = DateTime.Now;
                entity.IsCurrent = CurrentCheckBox.Checked;
                entity.Active = ActiveCheckBox.Checked;
                entity.TypeId = Monaco.Classroom.Ordering.ProductController.GetProductTypeByName(Globals.Settings.ProductType).Id;
                try
                {
                    Monaco.Classroom.Ordering.ProductController.InsertProduct(entity);

                    CreatePaymentOptionDialog.Reset();
                    BindDialog();
                    DataBind();
                    OnPaymentOptionCreated(EventArgs.Empty);
                    entity = null;
                }
                catch (Exception ex)
                {
                    throw ex;
                }

            }
        }
        else
        {
            ValidationHelper.SetFocusToFirstError(this.Page, "create_paymentoption");
        }
    }
    //protected void UpdatePaymentOptionDialog_OkButtonClicked(object sender, EventArgs e)
    //{
    //    if (Page.IsValid)
    //    {
    //        if (this.SKU != "")
    //        {
    //            PaymentOptions entity = new PaymentOptions();
    //            entity.Sku = this.SKU;
    //            entity.CourseID = _entity.CourseID;
    //            entity.TrialPeriodDays = Convert.ToInt32(TrialPeriodDaysTextBox.Text);
    //            entity.InitialPrice = Convert.ToDouble(InitialPriceTextBox.Text);
    //            entity.RecurringPrice = Convert.ToDouble(RecurringPriceTextBox.Text);
    //            //entity.SubscriptionDuration = Convert.ToInt32(SubscriptionDurationTextBox.Text);
    //            //entity.AvailableDuration = Convert.ToInt32(AvailableDurationTextBox.Text);

    //            // always is the person making the change...
    //            entity.LastUpdatedBy = this.Page.User.Identity.Name;

    //            int subscriptionDuration = 0;
    //            if (int.TryParse(SubscriptionDurationTextBox.Text, out subscriptionDuration))
    //                entity.SubscriptionDuration = subscriptionDuration;

    //            int availabilityDuration = 0;
    //            if (int.TryParse(AvailableDurationTextBox.Text, out availabilityDuration))
    //                entity.AvailableDuration = availabilityDuration;

    //            if (chkInfiniteSubscription.Checked)
    //            {
    //                entity.SubscriptionDuration = null;
    //            }

    //            if (chkInfinateAvailability.Checked)
    //            {
    //                entity.AvailableDuration = null;
    //            }

    //            // the database should take care of these things, you can t update when it was created
    //            //entity.CreatedOn = Convert.ToDateTime(CreatedOnLiteral.Text) ;
    //            //entity.LastUpdatedOn = DateTime.Now;

    //            entity.IsCurrent = UpdateCurrentCheckBox.Checked;
    //            entity.Active = UpdateActiveCheckBox.Checked;


    //            bool result = ProductController.UpdateProduct(entity);

    //            if (!result)
    //            {
    //                UpdatePaymentOptionDialog.Reset();
    //                this.BindDialog();
    //                DataBind();
    //                OnPaymentOptionUpdated(EventArgs.Empty);
    //                entity = null;

    //            }
    //        }
    //    }
    //    else
    //    {
    //        ValidationHelper.SetFocusToFirstError(this.Page, "update_paymentoption");
    //    }
    //}

    protected void DeletePaymentOptionButton_Click(object sender, EventArgs e)
    {
        Monaco.Classroom.Ordering.ProductController.DeleteProduct(this.SKU);
        Response.Redirect("PaymentOptions.aspx?CourseId=" + _entity.RefId);
        _entity = null;
    }