Deactivate() public method

Deletes this plan, making it inactive
public Deactivate ( ) : void
return void
コード例 #1
0
        public void CreatePlan()
        {
            Plan p = new Plan(Factories.GetMockPlanCode(), Factories.GetMockPlanName());
            p.SetupFeeInCents.Add("USD",500);
            p.AccountingCode = "accountingcode123";
            p.Description = "a test plan";
            p.DisplayDonationAmounts = true;
            p.DisplayPhoneNumber = false;
            p.DisplayQuantity = true;
            p.TotalBillingCycles = 5;
            p.TrialIntervalUnit = Plan.IntervalUnit.months;
            p.TrialIntervalLength = 1;
            p.PlanIntervalUnit = Plan.IntervalUnit.days;
            p.PlanIntervalLength = 180;
            p.Create();

            Assert.IsNotNull(p.CreatedAt);
            Assert.AreEqual(p.AccountingCode, "accountingcode123");
            Assert.AreEqual(p.Description, "a test plan");
            Assert.IsTrue(p.DisplayDonationAmounts.Value);
            Assert.IsFalse(p.DisplayPhoneNumber.Value);
            Assert.IsTrue(p.DisplayQuantity.Value);
            Assert.AreEqual(p.TotalBillingCycles, 5);
            Assert.AreEqual(p.TrialIntervalUnit, Plan.IntervalUnit.months);
            Assert.AreEqual(p.TrialIntervalLength, 1);
            Assert.AreEqual(p.PlanIntervalUnit, Plan.IntervalUnit.days);
            Assert.AreEqual(p.PlanIntervalLength, 180);
            p.Deactivate();
        }
コード例 #2
0
        public void ListCanceledSubscriptions()
        {
            String s = Factories.GetMockPlanCode();
            Plan p = new Plan(s, Factories.GetMockPlanName());
            p.Description = "Subscription Test";
            p.UnitAmountInCents.Add("USD", 400);
            p.Create();

            for (int x = 0; x < 2; x++)
            {
                String a = Factories.GetMockAccountName();
                Account acct = new Account(a, "New Txn", "User",
                    "4111111111111111", DateTime.Now.Month, DateTime.Now.Year + 1);

                Subscription sub = new Subscription(acct, p, "USD");
                sub.Create();

                sub.Cancel();
                Thread.Sleep(1);
            }

            SubscriptionList list = SubscriptionList.GetSubscriptions(Subscription.SubstriptionState.canceled);
            Assert.IsTrue(list.Count > 0);
            p.Deactivate();
        }
コード例 #3
0
        public void CreatePlanSmall()
        {
            Plan p = new Plan(Factories.GetMockPlanCode(), Factories.GetMockPlanName());
            p.SetupFeeInCents.Add("USD",100);
            p.Create();

            Assert.IsNotNull(p.CreatedAt);
            Assert.AreEqual(p.SetupFeeInCents["USD"], 100);
            p.Deactivate();
        }
コード例 #4
0
        public void CreateCouponPlan()
        {
            Plan p = new Plan(Factories.GetMockPlanCode("coupon plan"), "Coupon Test");
            p.SetupFeeInCents.Add("USD", 500);
            p.UnitAmountInCents.Add("USD", 5000);
            p.Create();

            string s = Factories.GetMockCouponCode();
            Coupon c = new Coupon(s, Factories.GetMockCouponName(), new Dictionary<string, int>());
            c.DiscountInCents.Add("USD", 100);
            c.Plans.Add(p.PlanCode);

            p.Deactivate();
        }
コード例 #5
0
        public void DeactivatePlan()
        {
            String s = Factories.GetMockPlanCode();
            Plan p = new Plan(s, Factories.GetMockPlanName());
            p.Description = "Test Delete";
            p.UnitAmountInCents.Add("USD", 100);
            p.Create();

            p = Plan.Get(s);
            Assert.IsNotNull(p.CreatedAt);
            Assert.AreEqual(p.UnitAmountInCents["USD"], 100);

            p.Deactivate();

            try
            {
                Plan p2 = Plan.Get(s);
                Assert.Fail("Plan has not been deactivated.");
            }
            catch (Exception)
            {
                // Expected
            }
        }
コード例 #6
0
        public void ListPastDueSubscriptions()
        {
            String s = Factories.GetMockPlanCode();
            Plan p = new Plan(s, Factories.GetMockPlanName());
            p.Description = "Subscription Test";
            p.PlanIntervalLength = 1;
            p.PlanIntervalUnit = Plan.IntervalUnit.months;
            p.UnitAmountInCents.Add("USD", 200100);
            p.Create();

            for (int x = 0; x < 2; x++)
            {
                String a = Factories.GetMockAccountName();
                Account acct = new Account(a, "New Txn", "User",
                "4111111111111111", DateTime.Now.Month, DateTime.Now.Year + 1);

                Subscription sub = new Subscription(acct, p, "USD");
                sub.Create();

                Thread.Sleep(1);
            }

            SubscriptionList list = SubscriptionList.GetSubscriptions(Subscription.SubstriptionState.past_due);
            Assert.IsTrue(list.Count > 0);

            p.Deactivate();
        }
コード例 #7
0
        public void ListForAccount()
        {
            String s = Factories.GetMockPlanCode();
            Plan p = new Plan(s, Factories.GetMockPlanName());
            p.Description = "Subscription Test";

            p.UnitAmountInCents.Add("USD", 400);
            p.Create();

            String s2 = Factories.GetMockPlanCode();
            Plan p2 = new Plan(s2, Factories.GetMockPlanName());
            p2.Description = "Subscription Test";

            p2.UnitAmountInCents.Add("USD", 500);
            p2.Create();

            String a = Factories.GetMockAccountName();
            Account acct = new Account(a, "New Txn", "User",
                "4111111111111111", DateTime.Now.Month, DateTime.Now.Year + 1);

            Subscription sub = new Subscription(acct, p, "USD");
            sub.Create();

            Subscription sub2 = new Subscription(acct, p2, "USD");
            sub2.Create();

            SubscriptionList list = acct.GetSubscriptions(Subscription.SubstriptionState.all);
            Assert.IsTrue(list.Count > 0);

            p.Deactivate();
            p2.Deactivate();
        }
コード例 #8
0
        public void LookupPlan()
        {
            String s = Factories.GetMockPlanCode();
            Plan p = new Plan(s, Factories.GetMockPlanName());
            p.Description = "Test Lookup";
            p.UnitAmountInCents.Add("USD", 100);
            p.Create();

            Plan l = Plan.Get(s);
            Assert.IsNotNull(l.CreatedAt);
            Assert.AreEqual(l.UnitAmountInCents["USD"], 100);
            Assert.AreEqual(l.PlanCode, s);
            Assert.AreEqual(l.Description, "Test Lookup");
            p.Deactivate();
        }
コード例 #9
0
        public void UpdatePlan()
        {
            String s = Factories.GetMockPlanCode();
            Plan p = new Plan(s, Factories.GetMockPlanName());
            p.Description = "Test Update";
            p.UnitAmountInCents.Add("USD", 100);
            p.Create();

            p.UnitAmountInCents["USD"] = 5000;
            p.SetupFeeInCents.Add("USD", 100);

            p.Update();

            p = Plan.Get(s);
            Assert.AreEqual(p.UnitAmountInCents["USD"], 5000);
            Assert.AreEqual(p.SetupFeeInCents["USD"], 100);
            p.Deactivate();
        }