当前位置: 首页>>代码示例>>C#>>正文


C# Plan.Create方法代码示例

本文整理汇总了C#中Plan.Create方法的典型用法代码示例。如果您正苦于以下问题:C# Plan.Create方法的具体用法?C# Plan.Create怎么用?C# Plan.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Plan的用法示例。


在下文中一共展示了Plan.Create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LookupCouponInvoice

        public void LookupCouponInvoice()
        {
            var discounts = new Dictionary<string, int> { { "USD", 1000 } };
            var coupon = new Coupon(GetMockCouponCode(), GetMockCouponName(), discounts);
            coupon.Create();

            var plan = new Plan(GetMockPlanCode(), GetMockPlanCode())
            {
                Description = "Test Lookup Coupon Invoice"
            };
            plan.UnitAmountInCents.Add("USD", 1500);
            plan.Create();
            PlansToDeactivateOnDispose.Add(plan);

            var account = CreateNewAccountWithBillingInfo();

            var redemption = account.RedeemCoupon(coupon.CouponCode, "USD");

            var sub = new Subscription(account, plan, "USD", coupon.CouponCode);
            sub.Create();

            // TODO complete this test

            var invoices = account.GetInvoices();

            invoices.Should().NotBeEmpty();

            var invoice = Invoices.Get(invoices.First().InvoiceNumber);
            var fromInvoice = invoice.GetRedemption();

            redemption.Should().Be(fromInvoice);
        }
开发者ID:kylelengling,项目名称:recurly-client-net,代码行数:32,代码来源:CouponRedemptionTest.cs

示例2: ListExpiredSubscriptions

        public void ListExpiredSubscriptions()
        {
            var plan = new Plan(GetMockPlanCode(), GetMockPlanName())
            {
                Description = "Subscription Test",
                PlanIntervalLength = 1,
                PlanIntervalUnit = Plan.IntervalUnit.Months
            };
            plan.UnitAmountInCents.Add("USD", 400);
            plan.Create();
            PlansToDeactivateOnDispose.Add(plan);

            for (var x = 0; x < 2; x++)
            {
                var account = CreateNewAccountWithBillingInfo();
                var sub = new Subscription(account, plan, "USD")
                {
                    StartsAt = DateTime.Now.AddMonths(-5)
                };

                sub.Create();
            }

            var subs = Subscriptions.List(Subscription.SubscriptionState.Expired);
            subs.Should().NotBeEmpty();
        }
开发者ID:Georotzen,项目名称:recurly-client-net,代码行数:26,代码来源:SubscriptionListTest.cs

示例3: CreatePlan

        public void CreatePlan()
        {
            var plan = new Plan(GetMockPlanCode(), GetMockPlanName())
            {
                AccountingCode = "accountingcode123",
                SetupFeeAccountingCode = "setupfeeac",
                Description = "a test plan",
                DisplayDonationAmounts = true,
                DisplayPhoneNumber = false,
                DisplayQuantity = true,
                TotalBillingCycles = 5,
                TrialIntervalUnit = Plan.IntervalUnit.Months,
                TrialIntervalLength = 1,
                PlanIntervalUnit = Plan.IntervalUnit.Days,
                PlanIntervalLength = 180
            };
            plan.SetupFeeInCents.Add("USD", 500);
            plan.Create();
            PlansToDeactivateOnDispose.Add(plan);

            plan.CreatedAt.Should().NotBe(default(DateTime));
            plan.AccountingCode.Should().Be("accountingcode123");
            plan.SetupFeeAccountingCode.Should().Be("setupfeeac");
            plan.Description.Should().Be("a test plan");
            plan.DisplayDonationAmounts.Should().HaveValue().And.Be(true);
            plan.DisplayPhoneNumber.Should().HaveValue().And.Be(false);
            plan.DisplayQuantity.Should().HaveValue().And.Be(true);
            plan.TotalBillingCycles.Should().Be(5);
            plan.TrialIntervalUnit.Should().Be(Plan.IntervalUnit.Months);
            plan.TrialIntervalLength.Should().Be(1);
            plan.PlanIntervalUnit.Should().Be(Plan.IntervalUnit.Days);
            plan.PlanIntervalLength.Should().Be(180);
        }
开发者ID:kylelengling,项目名称:recurly-client-net,代码行数:33,代码来源:PlanTest.cs

示例4: CreateSubscription

        public void CreateSubscription()
        {
            var plan = new Plan(GetMockPlanCode(), GetMockPlanName())
            {
                Description = "Create Subscription Test"
            };
            plan.UnitAmountInCents.Add("USD", 100);
            plan.Create();
            PlansToDeactivateOnDispose.Add(plan);

            var account = CreateNewAccountWithBillingInfo();

            var coup = CreateNewCoupon(3);
            var sub = new Subscription(account, plan, "USD");
            sub.TotalBillingCycles = 5;
            sub.Coupon = coup;
            Assert.Null(sub.TaxInCents);
            Assert.Null(sub.TaxType);
            Assert.Null(sub.TaxRate);
            sub.Create();

            sub.ActivatedAt.Should().HaveValue().And.NotBe(default(DateTime));
            sub.State.Should().Be(Subscription.SubscriptionState.Active);
            Assert.Equal(5, sub.TotalBillingCycles);
            Assert.Equal(coup.CouponCode, sub.Coupon.CouponCode);
            Assert.Equal(9, sub.TaxInCents.Value);
            Assert.Equal("usst", sub.TaxType);
            Assert.Equal(0.0875M, sub.TaxRate.Value);

            var sub1 = Subscriptions.Get(sub.Uuid);
            Assert.Equal(5, sub1.TotalBillingCycles);
        }
开发者ID:Georotzen,项目名称:recurly-client-net,代码行数:32,代码来源:SubscriptionTest.cs

示例5: CreatePlanSmall

        public void CreatePlanSmall()
        {
            var plan = new Plan(GetMockPlanCode(), GetMockPlanName());
            plan.SetupFeeInCents.Add("USD", 100);
            plan.Create();
            PlansToDeactivateOnDispose.Add(plan);

            plan.CreatedAt.Should().NotBe(default(DateTime));
            plan.SetupFeeInCents.Should().Contain("USD", 100);
        }
开发者ID:kylelengling,项目名称:recurly-client-net,代码行数:10,代码来源:PlanTest.cs

示例6: ListPlans

        public void ListPlans()
        {
            var plan = new Plan(GetMockPlanCode(), GetMockPlanName());
            plan.SetupFeeInCents.Add("USD", 100);
            plan.Create();
            PlansToDeactivateOnDispose.Add(plan);

            var plans = Plans.List();
            plans.Should().NotBeEmpty();
        }
开发者ID:Georotzen,项目名称:recurly-client-net,代码行数:10,代码来源:PlanListTest.cs

示例7: LookupPlan

        public void LookupPlan()
        {
            var plan = new Plan(GetMockPlanCode(), GetMockPlanName()) {Description = "Test Lookup"};
            plan.UnitAmountInCents.Add("USD", 100);
            plan.TaxExempt = true;
            plan.Create();
            PlansToDeactivateOnDispose.Add(plan);

            plan.CreatedAt.Should().NotBe(default(DateTime));

            var fromService = Plans.Get(plan.PlanCode);
            fromService.PlanCode.Should().Be(plan.PlanCode);
            fromService.UnitAmountInCents.Should().Contain("USD", 100);
            fromService.Description.Should().Be("Test Lookup");
            Assert.True(plan.TaxExempt.Value);
        }
开发者ID:kylelengling,项目名称:recurly-client-net,代码行数:16,代码来源:PlanTest.cs

示例8: ListActiveSubscriptions

        public void ListActiveSubscriptions()
        {
            var p = new Plan(GetMockPlanCode(), GetMockPlanName()) { Description = "Subscription Test" };
            p.UnitAmountInCents.Add("USD", 300);
            p.Create();
            PlansToDeactivateOnDispose.Add(p);

            for (var x = 0; x < 2; x++)
            {
                var account = CreateNewAccountWithBillingInfo();

                var sub = new Subscription(account, p, "USD");
                sub.Create();
            }

            var subs = Subscriptions.List(Subscription.SubscriptionState.Active);
            subs.Should().NotBeEmpty();
        }
开发者ID:Georotzen,项目名称:recurly-client-net,代码行数:18,代码来源:SubscriptionListTest.cs

示例9: CreateCouponPlan

        public void CreateCouponPlan()
        {
            var plan = new Plan(GetMockPlanCode("coupon plan"), "Coupon Test");
            plan.SetupFeeInCents.Add("USD", 500);
            plan.UnitAmountInCents.Add("USD", 5000);
            plan.Create();
            PlansToDeactivateOnDispose.Add(plan);

            var coupon = new Coupon(GetMockCouponCode(), GetMockCouponName(), new Dictionary<string, int>());
            coupon.DiscountInCents.Add("USD", 100);
            coupon.Plans.Add(plan.PlanCode);

            Action a = coupon.Create;
            a.ShouldNotThrow();
            Assert.Equal(1, coupon.Plans.Count);

            //plan.Deactivate(); BaseTest.Dispose() handles this
        }
开发者ID:Georotzen,项目名称:recurly-client-net,代码行数:18,代码来源:CouponTest.cs

示例10: UpdatePlan

        public void UpdatePlan()
        {
            var plan = new Plan(GetMockPlanCode(), GetMockPlanName()) {Description = "Test Update"};
            plan.UnitAmountInCents.Add("USD", 100);
            plan.Create();
            PlansToDeactivateOnDispose.Add(plan);

            plan.UnitAmountInCents["USD"] = 5000;
            plan.SetupFeeInCents["USD"] = 100;
            plan.TaxExempt = false;

            plan.Update();

            plan = Plans.Get(plan.PlanCode);
            plan.UnitAmountInCents.Should().Contain("USD", 5000);
            plan.SetupFeeInCents.Should().Contain("USD", 100);
            Assert.False(plan.TaxExempt.Value);
        }
开发者ID:kylelengling,项目名称:recurly-client-net,代码行数:18,代码来源:PlanTest.cs

示例11: DeactivatePlan

        public void DeactivatePlan()
        {
            // Arrange
            var plan = new Plan(GetMockPlanCode(), GetMockPlanName()) {Description = "Test Delete"};
            plan.UnitAmountInCents.Add("USD", 100);
            plan.Create();
            PlansToDeactivateOnDispose.Add(plan);

            plan = Plans.Get(plan.PlanCode);
            plan.CreatedAt.Should().NotBe(default(DateTime));
            plan.UnitAmountInCents.Should().Contain("USD", 100);

            //Act
            plan.Deactivate();

            //Assert
            Action get = () => Plans.Get(plan.PlanCode);
            get.ShouldThrow<NotFoundException>();
        }
开发者ID:Georotzen,项目名称:recurly-client-net,代码行数:19,代码来源:PlanTest.cs

示例12: LookupSubscription

        public void LookupSubscription()
        {
            var plan = new Plan(GetMockPlanCode(), GetMockPlanName()) {Description = "Lookup Subscription Test"};
            plan.UnitAmountInCents.Add("USD", 1500);
            plan.Create();
            PlansToDeactivateOnDispose.Add(plan);

            var account = CreateNewAccountWithBillingInfo();

            var sub = new Subscription(account, plan, "USD");
            sub.Create();

            sub.ActivatedAt.Should().HaveValue().And.NotBe(default(DateTime));
            sub.State.Should().Be(Subscription.SubscriptionState.Active);

            var fromService = Subscriptions.Get(sub.Uuid);

            fromService.Should().Be(sub);
        }
开发者ID:kylelengling,项目名称:recurly-client-net,代码行数:19,代码来源:SubscriptionTest.cs

示例13: CancelSubscription

        public void CancelSubscription()
        {
            var plan = new Plan(GetMockPlanCode(), GetMockPlanName())
            {
                Description = "Cancel Subscription Test"
            };
            plan.UnitAmountInCents.Add("USD", 100);
            plan.Create();
            PlansToDeactivateOnDispose.Add(plan);

            var account = CreateNewAccountWithBillingInfo();

            var sub = new Subscription(account, plan, "USD");
            sub.Create();

            sub.Cancel();

            sub.CanceledAt.Should().HaveValue().And.NotBe(default(DateTime));
            sub.State.Should().Be(Subscription.SubscriptionState.Canceled);
        }
开发者ID:Georotzen,项目名称:recurly-client-net,代码行数:20,代码来源:SubscriptionTest.cs

示例14: LookupSubscriptionPendingChanges

        public void LookupSubscriptionPendingChanges()
        {
            var plan = new Plan(GetMockPlanCode(), GetMockPlanName())
            {
                Description = "Lookup Subscription With Pending Changes Test"
            };
            plan.UnitAmountInCents.Add("USD", 1500);
            plan.Create();
            PlansToDeactivateOnDispose.Add(plan);

            var account = CreateNewAccountWithBillingInfo();

            var sub = new Subscription(account, plan, "USD");
            sub.Create();
            sub.UnitAmountInCents = 3000;
            
            sub.ChangeSubscription(Subscription.ChangeTimeframe.Renewal);

            var newSubscription = Subscriptions.Get(sub.Uuid);
            newSubscription.PendingSubscription.Should().NotBeNull();
            newSubscription.PendingSubscription.UnitAmountInCents.Should().Be(3000);
        }
开发者ID:kylelengling,项目名称:recurly-client-net,代码行数:22,代码来源:SubscriptionTest.cs

示例15: CreateSubscriptionPlanWithAddons

        public void CreateSubscriptionPlanWithAddons()
        {
            Plan plan = null;
            Plan plan2 = null;
            AddOn addon1 = null;
            AddOn addon2 = null;
            Account account = null;
            Subscription sub = null;
            Subscription sub2 = null;
            Subscription sub3 = null;

            try
            {
                plan = new Plan(GetMockPlanCode(), "aarons test plan")
                {
                    Description = "Create Subscription Plan With Addons Test"
                };
                plan.UnitAmountInCents.Add("USD", 100);
                plan.Create();

                addon1 = plan.NewAddOn("addon1", "addon1");
                addon1.DisplayQuantityOnHostedPage = true;
                addon1.UnitAmountInCents.Add("USD", 100);
                addon1.DefaultQuantity = 1;
                addon1.Create();

                plan = Plans.Get(plan.PlanCode);

                var addon_test_1 = plan.GetAddOn("addon1");
                Assert.Equal(addon1.UnitAmountInCents["USD"], addon_test_1.UnitAmountInCents["USD"]);

                plan2 = new Plan(GetMockPlanCode(), "aarons test plan 2")
                {
                    Description = "Create Subscription Plan With Addons Test 2"
                };
                plan2.UnitAmountInCents.Add("USD", 1900);
                plan2.Create();

                addon2 = plan2.NewAddOn("addon1", "addon2");
                addon2.DisplayQuantityOnHostedPage = true;
                addon2.UnitAmountInCents.Add("USD", 200);
                addon2.DefaultQuantity = 1;
                addon2.Create();

                var addon_test_2 = plan2.GetAddOn("addon1");
                Assert.Equal(addon2.UnitAmountInCents["USD"], addon_test_2.UnitAmountInCents["USD"]);

                account = CreateNewAccountWithBillingInfo();

                sub = new Subscription(account, plan, "USD");
                sub.AddOns.Add(new SubscriptionAddOn("addon1", 100, 1)); // TODO allow passing just the addon code
                sub.Create();

                // confirm that Create() doesn't duplicate the AddOns
                Assert.Equal(1, sub.AddOns.Count);

                sub.ActivatedAt.Should().HaveValue().And.NotBe(default(DateTime));
                sub.State.Should().Be(Subscription.SubscriptionState.Active);

                // test changing the plan of a subscription

                sub2 = Subscriptions.Get(sub.Uuid);
                sub2.UnitAmountInCents = plan2.UnitAmountInCents["USD"];
                sub2.Plan = plan2;

                foreach (var addOn in sub2.AddOns)
                {
                    addOn.UnitAmountInCents = plan2.UnitAmountInCents["USD"];
                }

                sub2.ChangeSubscription(Subscription.ChangeTimeframe.Now);

                // check if the changes were saved
                sub3 = Subscriptions.Get(sub2.Uuid);
                sub3.UnitAmountInCents.Should().Equals(plan2.UnitAmountInCents["USD"]);
                Assert.Equal(1, sub3.AddOns.Count);
                foreach (var addOn in sub3.AddOns)
                {
                    addOn.UnitAmountInCents.Should().Equals(plan2.UnitAmountInCents["USD"]);
                }

            } finally {
                if (sub != null) sub.Cancel();
                if (plan2 != null) plan2.Deactivate();
                if (plan != null) plan.Deactivate();
                if (account != null) account.Close();
            }
        }
开发者ID:Georotzen,项目名称:recurly-client-net,代码行数:88,代码来源:SubscriptionTest.cs


注:本文中的Plan.Create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。