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


C# SubscriptionRequest类代码示例

本文整理汇总了C#中SubscriptionRequest的典型用法代码示例。如果您正苦于以下问题:C# SubscriptionRequest类的具体用法?C# SubscriptionRequest怎么用?C# SubscriptionRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: ToXML_EnsuresUSLocaleForDecimals

        public void ToXML_EnsuresUSLocaleForDecimals()
        {
            CultureInfo existingCulture = CultureInfo.CurrentCulture;

            try
            {
#if netcore
                CultureInfo.CurrentCulture = new CultureInfo("it-IT");
#else
                Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("it-IT");
#endif

                TransactionRequest transactionRequest = new TransactionRequest
                {
                    Amount = 100.0M,
                    TaxAmount = 10.0M,
                };

                SubscriptionRequest subscriptionRequest = new SubscriptionRequest
                {
                    Price = 200.0M,
                };

                SubscriptionTransactionRequest subscriptionTransactionRequest = new SubscriptionTransactionRequest
                {
                    Amount = 300.0M
                };

                ModificationRequest modificationRequest = new ModificationRequest
                {
                    Amount = 400.0M
                };

                TestHelper.AssertIncludes("<amount>100.00</amount>", transactionRequest.ToXml());
                TestHelper.AssertIncludes("<tax-amount>10.00</tax-amount>", transactionRequest.ToXml());
                TestHelper.AssertIncludes("<price>200.00</price>", subscriptionRequest.ToXml());
                TestHelper.AssertIncludes("<amount>300.00</amount>", subscriptionTransactionRequest.ToXml());
                TestHelper.AssertIncludes("<amount>400.00</amount>", modificationRequest.ToXml("root"));
            }
            finally
            {
#if netcore
                CultureInfo.CurrentCulture = existingCulture;
#else
                Thread.CurrentThread.CurrentCulture = existingCulture;
#endif
            }
        }
开发者ID:braintree,项目名称:braintree_dotnet,代码行数:48,代码来源:RequestTest.cs

示例2: Create_SubscriptionWithoutTrial

        public void Create_SubscriptionWithoutTrial()
        {
            TestPlan plan = PlanFixture.PLAN_WITHOUT_TRIAL;

            SubscriptionRequest request = new SubscriptionRequest
            {
                PaymentMethodToken = creditCard.Token,
                PlanId = plan.Id
            };

            Result<Subscription> result = gateway.Subscription.Create(request);
            Assert.IsTrue(result.IsSuccess());
            Subscription subscription = result.Target;

            Assert.AreEqual(creditCard.Token, subscription.PaymentMethodToken);
            Assert.AreEqual(plan.Id, subscription.PlanId);
            Assert.AreEqual(MerchantAccountIDs.DEFAULT_MERCHANT_ACCOUNT_ID, subscription.MerchantAccountId);
            Assert.AreEqual(plan.Price, subscription.Price);
            Assert.AreEqual(plan.Price, subscription.NextBillAmount);
            Assert.AreEqual(plan.Price, subscription.NextBillingPeriodAmount);
            Assert.AreEqual(0.00M, subscription.Balance);
            Assert.IsTrue(Regex.IsMatch(subscription.Id, "^\\w{6}$"));
            Assert.AreEqual(SubscriptionStatus.ACTIVE, subscription.Status);
            Assert.AreEqual(0, subscription.FailureCount);
            Assert.IsFalse((bool)subscription.HasTrialPeriod);
            Assert.AreEqual(1, subscription.CurrentBillingCycle);

            Assert.IsTrue(subscription.BillingPeriodEndDate.HasValue);
            Assert.IsTrue(subscription.BillingPeriodStartDate.HasValue);
            Assert.IsTrue(subscription.NextBillingDate.HasValue);
            Assert.IsTrue(subscription.FirstBillingDate.HasValue);
            Assert.IsTrue(subscription.CreatedAt.HasValue);
            Assert.IsTrue(subscription.UpdatedAt.HasValue);
            Assert.IsTrue(subscription.PaidThroughDate.HasValue);

            Assert.AreEqual(SubscriptionStatus.ACTIVE, subscription.StatusHistory[0].Status);
            Assert.AreEqual(SubscriptionSource.API, subscription.StatusHistory[0].Source);
            Assert.AreEqual(plan.Price, subscription.StatusHistory[0].Price);
            Assert.AreEqual(0.00M, subscription.StatusHistory[0].Balance);
            Assert.AreEqual("USD", subscription.StatusHistory[0].CurrencyIsoCode);
            Assert.AreEqual("integration_trialless_plan", subscription.StatusHistory[0].PlanId);
        }
开发者ID:braintree,项目名称:braintree_dotnet,代码行数:42,代码来源:SubscriptionIntegrationTest.cs

示例3: ToXML_EnsuresUSLocaleForDecimals

        public void ToXML_EnsuresUSLocaleForDecimals()
        {
            System.Globalization.CultureInfo existingCulture = System.Globalization.CultureInfo.CurrentCulture;

            try
            {
                System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo("it-IT");

                TransactionRequest transactionRequest = new TransactionRequest
                {
                    Amount = 100.0M
                };

                SubscriptionRequest subscriptionRequest = new SubscriptionRequest
                {
                    Price = 200.0M,
                };

                SubscriptionTransactionRequest subscriptionTransactionRequest = new SubscriptionTransactionRequest
                {
                    Amount = 300.0M
                };

                ModificationRequest modificationRequest = new ModificationRequest
                {
                    Amount = 400.0M
                };

                TestHelper.AssertIncludes("<amount>100.0</amount>", transactionRequest.ToXml());
                TestHelper.AssertIncludes("<price>200.0</price>", subscriptionRequest.ToXml());
                TestHelper.AssertIncludes("<amount>300.0</amount>", subscriptionTransactionRequest.ToXml());
                TestHelper.AssertIncludes("<amount>400.0</amount>", modificationRequest.ToXml("root"));
            }
            finally
            {
                System.Threading.Thread.CurrentThread.CurrentCulture = existingCulture;
            }
        }
开发者ID:ronin1,项目名称:braintree_dotnet,代码行数:38,代码来源:RequestTest.cs

示例4: Search_OnMerchantAccountIdIs

        public void Search_OnMerchantAccountIdIs()
        {
            SubscriptionRequest request1 = new SubscriptionRequest
            {
                MerchantAccountId = MerchantAccountIDs.DEFAULT_MERCHANT_ACCOUNT_ID,
                PaymentMethodToken = creditCard.Token,
                PlanId = PlanFixture.PLAN_WITH_TRIAL.Id,
                Price = 2M
            };

            SubscriptionRequest request2 = new SubscriptionRequest
            {
                MerchantAccountId = MerchantAccountIDs.NON_DEFAULT_MERCHANT_ACCOUNT_ID,
                PaymentMethodToken = creditCard.Token,
                PlanId = PlanFixture.PLAN_WITH_TRIAL.Id,
                Price = 2M
            };

            Subscription defaultMerchantAccountSubscription = gateway.Subscription.Create(request1).Target;
            Subscription nonDefaultMerchantAccountSubscription = gateway.Subscription.Create(request2).Target;

            SubscriptionSearchRequest request = new SubscriptionSearchRequest().
                MerchantAccountId.Is(MerchantAccountIDs.NON_DEFAULT_MERCHANT_ACCOUNT_ID).
                Price.Is(2M);

            ResourceCollection<Subscription> collection = gateway.Subscription.Search(request);

            Assert.IsTrue(TestHelper.IncludesSubscription(collection, nonDefaultMerchantAccountSubscription));
            Assert.IsFalse(TestHelper.IncludesSubscription(collection, defaultMerchantAccountSubscription));
        }
开发者ID:ronin1,项目名称:braintree_dotnet,代码行数:30,代码来源:SubscriptionTest.cs

示例5: Search_OnInTrialPeriodIs

        public void Search_OnInTrialPeriodIs()
        {
            SubscriptionRequest request1 = new SubscriptionRequest
            {
                PaymentMethodToken = creditCard.Token,
                PlanId = PlanFixture.PLAN_WITH_TRIAL.Id
            };

            SubscriptionRequest request2 = new SubscriptionRequest
            {
                PaymentMethodToken = creditCard.Token,
                PlanId = PlanFixture.PLAN_WITHOUT_TRIAL.Id
            };

            Subscription trial = gateway.Subscription.Create(request1).Target;
            Subscription noTrial = gateway.Subscription.Create(request2).Target;

            SubscriptionSearchRequest request = new SubscriptionSearchRequest().
                InTrialPeriod.Is(true);

            ResourceCollection<Subscription> trialResults = gateway.Subscription.Search(request);

            Assert.IsTrue(TestHelper.IncludesSubscription(trialResults, trial));
            Assert.IsFalse(TestHelper.IncludesSubscription(trialResults, noTrial));

            request = new SubscriptionSearchRequest().
            InTrialPeriod.Is(false);

            ResourceCollection<Subscription> noTrialResults = gateway.Subscription.Search(request);

            Assert.IsTrue(TestHelper.IncludesSubscription(noTrialResults, noTrial));
            Assert.IsFalse(TestHelper.IncludesSubscription(noTrialResults, trial));
        }
开发者ID:ronin1,项目名称:braintree_dotnet,代码行数:33,代码来源:SubscriptionTest.cs

示例6: Create_HasTransactionOnCreateWithNoTrial

        public void Create_HasTransactionOnCreateWithNoTrial()
        {
            TestPlan plan = PlanFixture.PLAN_WITHOUT_TRIAL;
            SubscriptionRequest request = new SubscriptionRequest
            {
                PaymentMethodToken = creditCard.Token,
                PlanId = plan.Id,
                Price = 482.48M
            };

            Result<Subscription> result = gateway.Subscription.Create(request);
            Assert.IsTrue(result.IsSuccess());
            Subscription subscription = result.Target;
            Transaction transaction = subscription.Transactions[0];

            Assert.AreEqual(1, subscription.Transactions.Count);
            Assert.AreEqual(482.48M, transaction.Amount);
            Assert.AreEqual(TransactionType.SALE, transaction.Type);
            Assert.AreEqual(subscription.Id, transaction.SubscriptionId);
        }
开发者ID:ronin1,项目名称:braintree_dotnet,代码行数:20,代码来源:SubscriptionTest.cs

示例7: Find_FindsAssociatedSubscriptions

        public void Find_FindsAssociatedSubscriptions()
        {
            Customer customer = gateway.Customer.Create(new CustomerRequest()).Target;

            var creditCardRequest = new CreditCardRequest
            {
                CustomerId = customer.Id,
                Number = "5105105105105100",
                ExpirationDate = "05/12",
                CVV = "123"
            };

            CreditCard originalCreditCard = gateway.CreditCard.Create(creditCardRequest).Target;
            string id = Guid.NewGuid().ToString();
            var subscriptionRequest = new SubscriptionRequest
            {
                Id = id,
                PlanId = "integration_trialless_plan",
                PaymentMethodToken = originalCreditCard.Token,
                Price = 1.00M
            };
            gateway.Subscription.Create(subscriptionRequest);

            CreditCard creditCard = gateway.CreditCard.Find(originalCreditCard.Token);
            Subscription subscription = creditCard.Subscriptions[0];
            Assert.AreEqual(id, subscription.Id);
            Assert.AreEqual("integration_trialless_plan", subscription.PlanId);
            Assert.AreEqual(1.00M, subscription.Price);
        }
开发者ID:braintree,项目名称:braintree_dotnet,代码行数:29,代码来源:CreditCardIntegrationTest.cs

示例8: Create

        /// <summary>
        /// Creates a <see cref="Subscription"/>.
        /// </summary>
        /// <param name="request">
        /// The request.
        /// </param>
        /// <returns>
        /// The <see cref="Attempt{Subscription}"/>.
        /// </returns>
        public Attempt<Subscription> Create(SubscriptionRequest request)
        {
            Creating.RaiseEvent(new Core.Events.NewEventArgs<SubscriptionRequest>(request), this);

            LogHelper.Info<BraintreeTransactionApiService>(string.Format("Braintree create subscription attempt PlanID: {0}, Price: {1}", request.PlanId, request.Price));
            var attempt = this.TryGetApiResult(() => this.BraintreeGateway.Subscription.Create(request));

            if (!attempt.Success) return Attempt<Subscription>.Fail(attempt.Exception);

            var result = attempt.Result;

            if (result.IsSuccess())
            {
                Created.RaiseEvent(new Core.Events.NewEventArgs<Subscription>(result.Target), this);

                return Attempt<Subscription>.Succeed(result.Target);
            }

            var error = new BraintreeApiException(result.Errors, result.Message);

            LogHelper.Error<BraintreeSubscriptionApiService>("Failed to create a subscription", error);

            return Attempt<Subscription>.Fail(error);
        }
开发者ID:jlarc,项目名称:Merchello,代码行数:33,代码来源:BraintreeSubscriptionApiService.cs

示例9: Update

        /// <summary>
        /// Updates an existing subscription
        /// </summary>
        /// <param name="request">
        /// The request.
        /// </param>
        /// <returns>
        /// The <see cref="Attempt"/>.
        /// </returns>
        public Attempt<Subscription> Update(SubscriptionRequest request)
        {
            Updating.RaiseEvent(new SaveEventArgs<SubscriptionRequest>(request), this);

            var attempt = TryGetApiResult(() => BraintreeGateway.Subscription.Update(request.Id, request));

            if (!attempt.Success) return Attempt<Subscription>.Fail(attempt.Exception);

            var result = attempt.Result;

            if (result.IsSuccess())
            {
                Updated.RaiseEvent(new SaveEventArgs<Subscription>(result.Target), this);

                return Attempt<Subscription>.Succeed(result.Target);
            }

            var error = new BraintreeApiException(result.Errors, result.Message);

            LogHelper.Error<BraintreeSubscriptionApiService>("Failed to create a subscription", error);

            return Attempt<Subscription>.Fail(error);
        }
开发者ID:GaryLProthero,项目名称:Merchello,代码行数:32,代码来源:BraintreeSubscriptionApiService.cs

示例10: Search_OnPlanIdIs

        public void Search_OnPlanIdIs()
        {
            TestPlan triallessPlan = PlanFixture.PLAN_WITHOUT_TRIAL;
            TestPlan trialPlan = PlanFixture.PLAN_WITH_TRIAL;
            SubscriptionRequest request1 = new SubscriptionRequest
            {
                PaymentMethodToken = creditCard.Token,
                PlanId = trialPlan.Id,
                Price = 5M
            };

            SubscriptionRequest request2 = new SubscriptionRequest
            {
                PaymentMethodToken = creditCard.Token,
                PlanId = triallessPlan.Id,
                Price = 5M
            };

            Subscription trialSubscription = gateway.Subscription.Create(request1).Target;
            Subscription triallessSubscription = gateway.Subscription.Create(request2).Target;

            SubscriptionSearchRequest request = new SubscriptionSearchRequest().
                PlanId.Is(trialPlan.Id).
                Price.Is(5M);

            ResourceCollection<Subscription> collection = gateway.Subscription.Search(request);

            Assert.IsTrue(TestHelper.IncludesSubscription(collection, trialSubscription));
            Assert.IsFalse(TestHelper.IncludesSubscription(collection, triallessSubscription));
        }
开发者ID:ronin1,项目名称:braintree_dotnet,代码行数:30,代码来源:SubscriptionTest.cs

示例11: Create_WithBadAddOnParamsCorrectlyParsesValidationErrors

        public void Create_WithBadAddOnParamsCorrectlyParsesValidationErrors()
        {
            TestPlan plan = PlanFixture.ADD_ON_DISCOUNT_PLAN;
            SubscriptionRequest request = new SubscriptionRequest
            {
                PaymentMethodToken = creditCard.Token,
                PlanId = plan.Id,
                AddOns = new AddOnsRequest
                {
                    Update = new UpdateAddOnRequest[]
                    {
                        new UpdateAddOnRequest
                        {
                            ExistingId = "increase_10",
                            Amount = -200M
                        },
                        new UpdateAddOnRequest
                        {
                            ExistingId = "increase_20",
                            Quantity = -9
                        }
                    }
                }
            };

            Result<Subscription> result = gateway.Subscription.Create(request);
            Assert.IsFalse(result.IsSuccess());

            Assert.AreEqual(ValidationErrorCode.SUBSCRIPTION_MODIFICATION_AMOUNT_IS_INVALID,
                result.Errors.ForObject("Subscription").ForObject("AddOns").ForObject("Update").ForIndex(0).OnField("Amount")[0].Code);

            Assert.AreEqual(ValidationErrorCode.SUBSCRIPTION_MODIFICATION_QUANTITY_IS_INVALID,
                result.Errors.ForObject("Subscription").ForObject("AddOns").ForObject("Update").ForIndex(1).OnField("Quantity")[0].Code);
        }
开发者ID:ronin1,项目名称:braintree_dotnet,代码行数:34,代码来源:SubscriptionTest.cs

示例12: Create_CanAddAddOnsAndDiscounts

        public void Create_CanAddAddOnsAndDiscounts()
        {
            TestPlan plan = PlanFixture.ADD_ON_DISCOUNT_PLAN;
            SubscriptionRequest request = new SubscriptionRequest
            {
                PaymentMethodToken = creditCard.Token,
                PlanId = plan.Id,
                AddOns = new AddOnsRequest
                {
                    Add = new AddAddOnRequest[]
                    {
                        new AddAddOnRequest
                        {
                            InheritedFromId = "increase_30",
                            Amount = 35M,
                            NumberOfBillingCycles = 3,
                            Quantity = 8
                        }
                    },
                    Remove = new string[] { "increase_10", "increase_20" }
                },
                Discounts = new DiscountsRequest
                {
                    Add = new AddDiscountRequest[]
                    {
                        new AddDiscountRequest
                        {
                            InheritedFromId = "discount_15",
                            Amount = 17M,
                            NeverExpires = true,
                            Quantity = 9
                        }
                    },
                    Remove = new string[] { "discount_7", "discount_11" }
                }
            };

            Result<Subscription> result = gateway.Subscription.Create(request);
            Assert.IsTrue(result.IsSuccess());
            Subscription subscription = result.Target;

            Assert.AreEqual(1, subscription.AddOns.Count);

            Assert.AreEqual("increase_30", subscription.AddOns[0].Id);
            Assert.AreEqual(35M, subscription.AddOns[0].Amount);
            Assert.AreEqual(8, subscription.AddOns[0].Quantity);
            Assert.IsFalse(subscription.AddOns[0].NeverExpires.Value);
            Assert.AreEqual(3, subscription.AddOns[0].NumberOfBillingCycles);
            Assert.AreEqual(0, subscription.AddOns[0].CurrentBillingCycle);

            Assert.AreEqual(1, subscription.Discounts.Count);

            Assert.AreEqual("discount_15", subscription.Discounts[0].Id);
            Assert.AreEqual(17M, subscription.Discounts[0].Amount);
            Assert.AreEqual(9, subscription.Discounts[0].Quantity);
            Assert.IsTrue(subscription.Discounts[0].NeverExpires.Value);
            Assert.IsNull(subscription.Discounts[0].NumberOfBillingCycles);
            Assert.AreEqual(0, subscription.Discounts[0].CurrentBillingCycle);
        }
开发者ID:ronin1,项目名称:braintree_dotnet,代码行数:59,代码来源:SubscriptionTest.cs

示例13: Create_CanRemoveInheritedAddOnsAndDiscounts

        public void Create_CanRemoveInheritedAddOnsAndDiscounts()
        {
            TestPlan plan = PlanFixture.ADD_ON_DISCOUNT_PLAN;
            SubscriptionRequest request = new SubscriptionRequest
            {
                PaymentMethodToken = creditCard.Token,
                PlanId = plan.Id,
                AddOns = new AddOnsRequest
                {
                    Remove = new string[] { "increase_10", "increase_20" }
                },
                Discounts = new DiscountsRequest
                {
                    Remove = new string[] { "discount_11" }
                }
            };

            Result<Subscription> result = gateway.Subscription.Create(request);
            Assert.IsTrue(result.IsSuccess());
            Subscription subscription = result.Target;

            Assert.AreEqual(0, subscription.AddOns.Count);
            Assert.AreEqual(1, subscription.Discounts.Count);

            Assert.AreEqual("discount_7", subscription.Discounts[0].Id);
        }
开发者ID:ronin1,项目名称:braintree_dotnet,代码行数:26,代码来源:SubscriptionTest.cs

示例14: Create_CanOverrideInheritedAddOnsAndDiscountsFromPlan

        public void Create_CanOverrideInheritedAddOnsAndDiscountsFromPlan()
        {
            TestPlan plan = PlanFixture.ADD_ON_DISCOUNT_PLAN;
            SubscriptionRequest request = new SubscriptionRequest
            {
                PaymentMethodToken = creditCard.Token,
                PlanId = plan.Id,
                AddOns = new AddOnsRequest
                {
                    Update = new UpdateAddOnRequest[]
                    {
                        new UpdateAddOnRequest
                        {
                            ExistingId = "increase_10",
                            Amount = 30M,
                            Quantity = 9,
                            NeverExpires = true
                        },
                        new UpdateAddOnRequest
                        {
                            ExistingId = "increase_20",
                            Amount = 40M,
                            NumberOfBillingCycles = 20
                        }
                    }
                },
                Discounts = new DiscountsRequest
                {
                    Update = new UpdateDiscountRequest[]
                    {
                        new UpdateDiscountRequest
                        {
                            ExistingId = "discount_7",
                            Amount = 15M,
                            Quantity = 7,
                            NeverExpires = true
                        },
                        new UpdateDiscountRequest
                        {
                            ExistingId = "discount_11",
                            Amount = 23M,
                            NumberOfBillingCycles = 11
                        }
                    }
                }
            };

            Result<Subscription> result = gateway.Subscription.Create(request);
            Assert.IsTrue(result.IsSuccess());
            Subscription subscription = result.Target;

            List<AddOn> addOns = subscription.AddOns;
            addOns.Sort(TestHelper.CompareModificationsById);

            Assert.AreEqual(2, addOns.Count);

            Assert.AreEqual(30M, addOns[0].Amount);
            Assert.AreEqual(9, addOns[0].Quantity);
            Assert.IsTrue(addOns[0].NeverExpires.Value);
            Assert.IsNull(addOns[0].NumberOfBillingCycles);
            Assert.AreEqual(0, addOns[0].CurrentBillingCycle);

            Assert.AreEqual(40.00M, addOns[1].Amount);
            Assert.AreEqual(1, addOns[1].Quantity);
            Assert.IsFalse(addOns[1].NeverExpires.Value);
            Assert.AreEqual(20, addOns[1].NumberOfBillingCycles);
            Assert.AreEqual(0, addOns[1].CurrentBillingCycle);

            List<Discount> discounts = subscription.Discounts;
            discounts.Sort(TestHelper.CompareModificationsById);

            Assert.AreEqual(2, discounts.Count);

            Assert.AreEqual(23M, discounts[0].Amount);
            Assert.AreEqual(1, discounts[0].Quantity);
            Assert.IsFalse(discounts[0].NeverExpires.Value);
            Assert.AreEqual(11, discounts[0].NumberOfBillingCycles);
            Assert.AreEqual(0, discounts[0].CurrentBillingCycle);

            Assert.AreEqual(15M, discounts[1].Amount);
            Assert.AreEqual(7, discounts[1].Quantity);
            Assert.IsTrue(discounts[1].NeverExpires.Value);
            Assert.IsNull(discounts[1].NumberOfBillingCycles);
            Assert.AreEqual(0, discounts[1].CurrentBillingCycle);
        }
开发者ID:ronin1,项目名称:braintree_dotnet,代码行数:85,代码来源:SubscriptionTest.cs

示例15: Create_InheritsAddOnsAndDiscountsFromPlan

        public void Create_InheritsAddOnsAndDiscountsFromPlan() {
            TestPlan plan = PlanFixture.ADD_ON_DISCOUNT_PLAN;
            SubscriptionRequest request = new SubscriptionRequest
            {
                PaymentMethodToken = creditCard.Token,
                PlanId = plan.Id
            };

            Result<Subscription> result = gateway.Subscription.Create(request);
            Assert.IsTrue(result.IsSuccess());
            Subscription subscription = result.Target;

            List<AddOn> addOns = subscription.AddOns;
            addOns.Sort(TestHelper.CompareModificationsById);

            Assert.AreEqual(2, addOns.Count);

            Assert.AreEqual(10M, addOns[0].Amount);
            Assert.AreEqual(1, addOns[0].Quantity);
            Assert.IsTrue(addOns[0].NeverExpires.Value);
            Assert.IsNull(addOns[0].NumberOfBillingCycles);
            Assert.AreEqual(0, addOns[0].CurrentBillingCycle);

            Assert.AreEqual(20.00M, addOns[1].Amount);
            Assert.AreEqual(1, addOns[1].Quantity);
            Assert.IsTrue(addOns[1].NeverExpires.Value);
            Assert.IsNull(addOns[1].NumberOfBillingCycles);
            Assert.AreEqual(0, addOns[1].CurrentBillingCycle);

            List<Discount> discounts = subscription.Discounts;
            discounts.Sort(TestHelper.CompareModificationsById);

            Assert.AreEqual(2, discounts.Count);

            Assert.AreEqual(11M, discounts[0].Amount);
            Assert.AreEqual(1, discounts[0].Quantity);
            Assert.IsTrue(discounts[0].NeverExpires.Value);
            Assert.IsNull(discounts[0].NumberOfBillingCycles);
            Assert.AreEqual(0, discounts[0].CurrentBillingCycle);

            Assert.AreEqual(7M, discounts[1].Amount);
            Assert.AreEqual(1, discounts[1].Quantity);
            Assert.IsTrue(discounts[1].NeverExpires.Value);
            Assert.IsNull(discounts[1].NumberOfBillingCycles);
            Assert.AreEqual(0, discounts[1].CurrentBillingCycle);
        }
开发者ID:ronin1,项目名称:braintree_dotnet,代码行数:46,代码来源:SubscriptionTest.cs


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