public void UserIdTest()
 {
     SubscriptionInfo target = new SubscriptionInfo(); // TODO: Initialize to an appropriate value
     Guid expected = new Guid(); // TODO: Initialize to an appropriate value
     Guid actual;
     target.UserId = expected;
     actual = target.UserId;
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
        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;

             
        }
Example #3
0
        public static SubscriptionInfo ToSubscription(this DataRow row)
        {
            SubscriptionInfo entity = new SubscriptionInfo();

            if (row["Id"] != System.DBNull.Value)
                entity.Id = (Guid)row["Id"];
            if (row["GatewayId"] != System.DBNull.Value)
                entity.GatewayId = (Guid)row["GatewayId"];
            if (row["CreditCardId"] != System.DBNull.Value)
                entity.CreditCardId = (Guid)row["CreditCardId"];
            if (row["RefId"] != System.DBNull.Value)
                entity.RefId = (Guid)row["RefId"];
            if (row["UserId"] != System.DBNull.Value)
                entity.UserId = (Guid)row["UserId"];
            if (row["CreateDate"] != System.DBNull.Value)
                entity.CreateDate = (DateTime)row["CreateDate"];
            if (row["StartDate"] != System.DBNull.Value)
                entity.StartDate = (DateTime)row["StartDate"];
            if (row["LastProcessedDate"] != System.DBNull.Value)
                entity.LastProcessedDate = (DateTime)row["LastProcessedDate"];
            if (row["IntervalType"] != System.DBNull.Value)
                entity.IntervalType = (IntervalType)Enum.ToObject(typeof(IntervalType), (short)row["IntervalType"]);
            if (row["IntervalLength"] != System.DBNull.Value)
                entity.IntervalLength = (Int32)row["IntervalLength"];
            if (row["TotalOccurrences"] != System.DBNull.Value)
                entity.TotalOccurrences = (Int32)row["TotalOccurrences"];
            if (row["TrialOccurrences"] != System.DBNull.Value)
                entity.TrialOccurrences = (Int32)row["TrialOccurrences"];
            if (row["TotalOcurrencesDone"] != System.DBNull.Value)
                entity.TotalOccurrencesDone = (Int32)row["TotalOcurrencesDone"];
            if (row["TrialOcurrencesDone"] != System.DBNull.Value)
                entity.TrialOccurrencesDone = (Int32)row["TrialOcurrencesDone"];
            if (row["Status"] != System.DBNull.Value)
                entity.Status = (BillingStatus)Enum.ToObject(typeof(BillingStatus), (short)row["Status"]);
            if (row["Amount"] != System.DBNull.Value)
                entity.Amount = (decimal)row["Amount"];
            if (row["TrialAmount"] != System.DBNull.Value)
                entity.TrialAmount = (decimal)row["TrialAmount"];

            return entity;
        }
Example #4
0
        protected static void Process(SubscriptionInfo sub, bool testTransaction)
        {
            GatewayInfo gateway = GetGateway(sub.GatewayId);
            GatewayTypeInfo gatewayType = GetGatewayType(gateway.GatewayTypeId);
            ICustomer customer = GetCustomer(sub.UserId);
            CreditCardInfo card = GetCreditCard(sub.CreditCardId);
            TransactionInfo transactionInfo = null;
            LoadProviders();

            transactionInfo = _providers[gatewayType.ProviderName].ProcessSubscription(ref sub, gateway, gatewayType, customer, card, false/*IsTrial*/, testTransaction);

            UpdateSubscription(ref sub);
            CreateTransaction(ref transactionInfo);
        }
Example #5
0
        public static void CancelSubscription(SubscriptionInfo info)
        {
            DbCommand cmd = SqlHelpers.CreateCommand(ConnectionString);
            cmd.CommandText = @"bill_Subscription_Delete";
            cmd.AddInputParam("@Id", DbType.Guid, info.Id);
            int affectedRows = SqlHelpers.ExecuteNonQuery(cmd);

        }
Example #6
0
        public static void UpdateSubscription(ref SubscriptionInfo entity)
        {
            DbCommand cmd = SqlHelpers.CreateCommand(ConnectionString);
            cmd.CommandText = @"bill_Subscription_Update";
            cmd.AddInputParam("@Id", DbType.Guid, entity.Id);
            cmd.AddInputParam("@UserId", DbType.Guid, entity.UserId);
            cmd.AddInputParam("@CreateDate", DbType.DateTime, entity.CreateDate);
            cmd.AddInputParam("@StartDate", DbType.DateTime, entity.StartDate);

            if (entity.LastProcessedDate == DateTime.MinValue)
                cmd.AddInputParam("@LastProcessedDate", DbType.DateTime, DBNull.Value);
            else
                cmd.AddInputParam("@LastProcessedDate", DbType.DateTime, entity.LastProcessedDate);

            cmd.AddInputParam("@LastProcessingStatus", DbType.Int16, entity.LastProcessingStatus);
            cmd.AddInputParam("@IntervalType", DbType.Int16, entity.IntervalType);
            cmd.AddInputParam("@IntervalLength", DbType.Int32, entity.IntervalLength);
            cmd.AddInputParam("@TotalOccurrences", DbType.Int32, entity.TotalOccurrences);
            cmd.AddInputParam("@TrialOccurrences", DbType.Int32, entity.TrialOccurrences);
            cmd.AddInputParam("@TotalOcurrencesDone", DbType.Int32, entity.TotalOccurrencesDone);
            cmd.AddInputParam("@TrialOcurrencesDone", DbType.Int32, entity.TrialOccurrencesDone);
            cmd.AddInputParam("@Status", DbType.Int16, entity.Status);
            cmd.AddInputParam("@Amount", DbType.Currency, entity.Amount);
            cmd.AddInputParam("@TrialAmount", DbType.Currency, entity.TrialAmount);

            int affectedRows = SqlHelpers.ExecuteNonQuery(cmd);
        }
Example #7
0
 public static void CreateSubscription(ref SubscriptionInfo entity)
 {
     DbCommand cmd = SqlHelpers.CreateCommand(ConnectionString);
     cmd.CommandText = @"bill_Subscription_Insert";
     cmd.AddInputParam("@Id", DbType.Guid, entity.Id);
     //cmd.AddInputParam("@ApplicationId", DbType.Guid, System.Web.Security.Membership);
     cmd.AddInputParam("@UserId", DbType.Guid, entity.UserId);
     cmd.AddInputParam("@CreditCardId", DbType.Guid, entity.CreditCardId);
     cmd.AddInputParam("@GatewayId", DbType.Guid, entity.GatewayId);
     cmd.AddInputParam("@RefId", DbType.Guid, entity.RefId);
     cmd.AddInputParam("@CreateDate", DbType.DateTime, entity.CreateDate);
     cmd.AddInputParam("@StartDate", DbType.DateTime, entity.StartDate);
     cmd.AddInputParam("@IntervalType", DbType.Int16, entity.IntervalType);
     cmd.AddInputParam("@IntervalLength", DbType.Int32, (int)entity.IntervalLength);
     cmd.AddInputParam("@TotalOccurrences", DbType.Int32, entity.TotalOccurrences);
     cmd.AddInputParam("@TrialOccurrences", DbType.Int32, entity.TrialOccurrences);
     cmd.AddInputParam("@TotalOcurrencesDone", DbType.Int32, entity.TotalOccurrencesDone);
     cmd.AddInputParam("@TrialOcurrencesDone", DbType.Int32, entity.TrialOccurrencesDone);
     cmd.AddInputParam("@Status", DbType.Int16, entity.Status);
     cmd.AddInputParam("@Amount", DbType.Currency, entity.Amount);
     cmd.AddInputParam("@TrialAmount", DbType.Currency, entity.TrialAmount);
     cmd.AddInputParam("@ApplicationName", DbType.String, System.Web.Security.Membership.ApplicationName);
     int affectedRows = SqlHelpers.ExecuteNonQuery(cmd);
 }
 protected void BindSubscription()
 {
     _subscription = BillingController.GetSubscriptionsByID(this.SubscriptionId);
 }
 public void TrialOccurrencesDoneTest()
 {
     SubscriptionInfo target = new SubscriptionInfo(); // TODO: Initialize to an appropriate value
     int expected = 0; // TODO: Initialize to an appropriate value
     int actual;
     target.TrialOccurrencesDone = expected;
     actual = target.TrialOccurrencesDone;
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
 public void AmountTest()
 {
     SubscriptionInfo target = new SubscriptionInfo(); // TODO: Initialize to an appropriate value
     Decimal expected = new Decimal(); // TODO: Initialize to an appropriate value
     Decimal actual;
     target.Amount = expected;
     actual = target.Amount;
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
 public void SubscriptionInfoConstructorTest()
 {
     SubscriptionInfo target = new SubscriptionInfo();
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
 public void CreateDateTest()
 {
     SubscriptionInfo target = new SubscriptionInfo(); // TODO: Initialize to an appropriate value
     DateTime expected = new DateTime(); // TODO: Initialize to an appropriate value
     DateTime actual;
     target.CreateDate = expected;
     actual = target.CreateDate;
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
 public void FriendlySubscriptionIDTest()
 {
     SubscriptionInfo target = new SubscriptionInfo(); // TODO: Initialize to an appropriate value
     string actual;
     actual = target.FriendlySubscriptionID;
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
 public void LastProcessingStatusTest()
 {
     SubscriptionInfo target = new SubscriptionInfo(); // TODO: Initialize to an appropriate value
     TransactionStatus expected = new TransactionStatus(); // TODO: Initialize to an appropriate value
     TransactionStatus actual;
     target.LastProcessingStatus = expected;
     actual = target.LastProcessingStatus;
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
 public void NextProcessDateTest()
 {
     SubscriptionInfo target = new SubscriptionInfo(); // TODO: Initialize to an appropriate value
     DateTime actual;
     actual = target.NextProcessDate;
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
Example #16
0
 public abstract TransactionInfo ProcessSubscription(ref SubscriptionInfo sub, GatewayInfo gateway, GatewayTypeInfo gatewayType, ICustomer customer, CreditCardInfo card, bool isTrial, bool testTransaction);