public void Process(Monaco.Classroom.Ordering.ProductProcessor processor) { bool inserted = false; try { inserted = ClassroomController.InsertEnrollment(processor.Order.CustomerID, processor.Order.Sku); } catch (SqlException ex) { WebExceptionEvent evnt = new WebExceptionEvent("Critical SQL Error", this, WebEventCodes.WebExtendedBase + 1230235, ex); evnt.Raise(); } catch (Exception ex) { WebExceptionEvent evnt = new WebExceptionEvent("Critical Unknown Error", this, WebEventCodes.WebExtendedBase + 1230236, ex); evnt.Raise(); } 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(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; } }
public void Process(Monaco.Classroom.Ordering.ProductProcessor processor) { processor.ContinueNow = false; OrderItem orderItem = processor.Order; Product product = ProductController.GetProduct(orderItem.Sku); double amountToAuthorize = product.InitialPrice + product.RecurringPrice; GatewayInfo gateway = BillingController.GetGateway(product.GatewayId); CreditCardInfo card = BillingController.GetCreditCard(orderItem.CreditCardId); GatewayTypeInfo gatewayType = BillingController.GetGatewayType(gateway.GatewayTypeId); Monaco.Billing.Provider.Customer customer = BillingController.GetCustomer(orderItem.CustomerID); // dont need to run on a $0 price if (amountToAuthorize > 0) { // see if the transaction approves TransactionInfo transaction = BillingController.PreAuthorize(gateway, gatewayType, orderItem.ID, customer, card, (decimal)amountToAuthorize, orderItem.TestMode); if (transaction.Status != TransactionStatus.Approved) { processor.OnOrderFailure(new OrderFailureEventArgs("Credit Card Declined")); processor.ContinueNow = false; } else { processor.Order.UpdateStatus(processor.Order.Status + 1); /* Updating generated order id in transaction table for current transaction */ transaction.OrderId = processor.Order.ID; BillingController.UpdateTransaction(ref transaction); processor.ContinueNow = true; } } else { processor.Order.UpdateStatus(processor.Order.Status + 1); processor.ContinueNow = true; } }