public void Process(ProductProcessor processor) { // get a list of skus from the current sku.. // create new database table that contains the package information //string[] skus = GetPackageSkus(processor.Order.Sku); List<CoursePackage> coursePackageSkuList = GetPackageSkus(processor.Order.Sku); bool inserted = true; ClassroomController.InsertEnrollment(processor.Order.CustomerID, "Basic"); ClassroomController.InsertEnrollment(processor.Order.CustomerID, "Advanced"); if (inserted) { //processor.Order.OnOrderSucceeded(EventArgs.Empty); processor.Order.UpdateStatus(processor.Order.Status + 1); processor.ContinueNow = true; } else { processor.OnOrderFailure(new OrderFailureEventArgs("Unable to create enrollment")); processor.ContinueNow = false; } }
public void Process(ProductProcessor processor) { processor.ContinueNow = false; //Cathexis.Entities.OrderItem orderItem = processor.Order; // Product product = ProductController.GetProduct(orderItem.Sku); double amountToAuthorize=0; // double amountToAuthorize = product.InitialPrice; //GatewayInfo gateway = BillingController.GetGateway(product.GatewayId); //CreditCardInfo card = BillingController.GetCreditCard(orderItem.CreditCardId); //GatewayTypeInfo gatewayType = BillingController.GetGatewayType(gateway.GatewayTypeId); //Customer customer = BillingController.GetCustomer(orderItem.CustomerID); //GatewayInfo gateway = BillingController.GetGateway() ; //CreditCardInfo card = BillingController.GetCreditCard(orderItem.CreditCardId); //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 = false; } } else { processor.Order.UpdateStatus(processor.Order.Status + 1); processor.ContinueNow = false; } }
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 { Monaco.Classroom.Ordering.Product product = Monaco.Classroom.Ordering.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); Monaco.Billing.Entities.OrderItem item = new Monaco.Billing.Entities.OrderItem(this.Sku, (Guid)Membership.GetUser().ProviderUserKey, card.Id, MembershipSettings.ConfigSettings.Website.Debug, Session.SessionID); Monaco.Classroom.Ordering.ProductProcessor processor = new Monaco.Classroom.Ordering.ProductProcessor(item); processor.OrderFailure += new Monaco.Classroom.Ordering.OrderFailureEventHandler(processor_OrderFailure); processor.OrderSuccess += new Monaco.Classroom.Ordering.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 Monaco.Classroom.Ordering.OrderSuccessEventArgs(item)); else processor.OnOrderFailure(new Monaco.Classroom.Ordering.OrderFailureEventArgs("unable to complete transaction")); } //catch (OrderSaveException ex) catch (Exception ex) { // raise a critical event... if (ex.InnerException != null) this.ErrorMessage.Text = ex.InnerException.Message; } } }