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


C# Braintree.SubscriptionRequest类代码示例

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


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

示例1: Index

        public ActionResult Index()
        {
            var customerRequest = new CustomerSearchRequest().
                Id.Is(Request.QueryString["id"]);
            ResourceCollection<Customer> customers = Constants.Gateway.Customer.Search(customerRequest);
            // There should only ever be one customer with the given ID
            Customer customer = customers.FirstItem;
            string PaymentMethodToken = customer.CreditCards[0].Token;
            var SubscriptionRequest = new SubscriptionRequest
            {
                PaymentMethodToken = PaymentMethodToken,
                PlanId = "test_plan_1"
            };
            Result<Subscription> result = Constants.Gateway.Subscription.Create(SubscriptionRequest);

            if (result.IsSuccess())
            {
                ViewData["Message"] = result.Target.Status;
            }
            else
            {
                ViewData["Message"] = string.Join(", ", result.Errors.DeepAll());
            }

            return View();
        }
开发者ID:bnitti,项目名称:braintree_dotnet_guide,代码行数:26,代码来源:HomeController.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(MerchantAccount.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((Boolean)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.PaidThroughDate.HasValue);
        }
开发者ID:toantran,项目名称:braintree_dotnet,代码行数:33,代码来源:SubscriptionTest.cs

示例3: Create_ReturnsDeclinedTransaction

        public void Create_ReturnsDeclinedTransaction()
        {
            Plan plan = Plan.PLAN_WITHOUT_TRIAL;

            SubscriptionRequest request = new SubscriptionRequest
            {
                PaymentMethodToken = creditCard.Token,
                PlanId = plan.Id,
                Price = SandboxValues.TransactionAmount.DECLINE
            };

            Result<Subscription> result = gateway.Subscription.Create(request);
            Assert.IsFalse(result.IsSuccess());
            Assert.AreEqual(TransactionStatus.PROCESSOR_DECLINED, result.Transaction.Status);
        }
开发者ID:sdether,项目名称:braintree_dotnet,代码行数:15,代码来源:SubscriptionTest.cs

示例4: Create_SubscriptionReturnsATransactionWithSubscriptionBillingPeriod

        public void Create_SubscriptionReturnsATransactionWithSubscriptionBillingPeriod()
        {
            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;
            Transaction transaction = subscription.Transactions[0];

            Assert.AreEqual(subscription.BillingPeriodStartDate, transaction.Subscription.BillingPeriodStartDate);
            Assert.AreEqual(subscription.BillingPeriodEndDate, transaction.Subscription.BillingPeriodEndDate);
        }
开发者ID:toantran,项目名称:braintree_dotnet,代码行数:18,代码来源:SubscriptionTest.cs

示例5: Create

        public ActionResult Create(string id)
        {
            try
            {
                Customer customer = Constants.Gateway.Customer.Find(id);
                string paymentMethodToken = customer.CreditCards[0].Token;

                SubscriptionRequest request = new SubscriptionRequest
                {
                    PaymentMethodToken = paymentMethodToken,
                    PlanId = "test_plan_1"
                };
                Result<Subscription> result = Constants.Gateway.Subscription.Create(request);

                return Content("Subscription Status " + result.Target.Status);
            }
            catch (Braintree.Exceptions.NotFoundException e)
            {
                return Content("No customer found for id: " + id);
            }
        }
开发者ID:bnitti,项目名称:braintree_dotnet_guide,代码行数:21,代码来源:SubscriptionsController.cs

示例6: 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:zxed,项目名称:braintree_dotnet,代码行数:38,代码来源:RequestTest.cs

示例7: Create

        public virtual Result<Subscription> Create(SubscriptionRequest request)
        {
            XmlNode subscriptionXML = service.Post(service.MerchantPath() + "/subscriptions", request);

            return new ResultImpl<Subscription>(new NodeWrapper(subscriptionXML), gateway);
        }
开发者ID:kevlut,项目名称:braintree_dotnet,代码行数:6,代码来源:SubscriptionGateway.cs

示例8: 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:Jammyhammy,项目名称:braintree_dotnet,代码行数:29,代码来源:CreditCardTest.cs

示例9: Search_OnNextBillingDate

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

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

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

            SubscriptionSearchRequest request = new SubscriptionSearchRequest().
                NextBillingDate.GreaterThanOrEqualTo(DateTime.Now.AddDays(5));

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

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

示例10: 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:zxed,项目名称:braintree_dotnet,代码行数:30,代码来源:SubscriptionTest.cs

示例11: Create_SubscriptionWithPaymentMethodNonce

        public void Create_SubscriptionWithPaymentMethodNonce()
        {
            TestPlan plan = PlanFixture.PLAN_WITHOUT_TRIAL;
            String nonce = TestHelper.GenerateUnlockedNonce(gateway, "4242424242424242", creditCard.CustomerId);
            SubscriptionRequest request = new SubscriptionRequest
            {
                PaymentMethodNonce = nonce,
                PlanId = plan.Id
            };

            Result<Subscription> result = gateway.Subscription.Create(request);
            Assert.IsTrue(result.IsSuccess());
            Subscription subscription = result.Target;
            Transaction transaction = subscription.Transactions[0];
            Assert.AreEqual("424242", transaction.CreditCard.Bin);
        }
开发者ID:zxed,项目名称:braintree_dotnet,代码行数:16,代码来源:SubscriptionTest.cs

示例12: Search_OnDaysPastDueBetween

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

            Subscription subscription = gateway.Subscription.Create(subscriptionRequest).Target;
            MakePastDue(subscription, 3);

            SubscriptionSearchRequest request = new SubscriptionSearchRequest().
                DaysPastDue.Between(2, 10);

            ResourceCollection<Subscription> collection = gateway.Subscription.Search(request);
            Assert.IsTrue(collection.MaximumCount > 0);

            foreach (Subscription foundSubscription in collection) {
                Assert.IsTrue(foundSubscription.DaysPastDue >= 2 && foundSubscription.DaysPastDue <= 10);
            }
        }
开发者ID:zxed,项目名称:braintree_dotnet,代码行数:21,代码来源:SubscriptionTest.cs

示例13: 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:zxed,项目名称:braintree_dotnet,代码行数:20,代码来源:SubscriptionTest.cs

示例14: Create_SetMerchantAccountId

        public void Create_SetMerchantAccountId()
        {
            TestPlan plan = PlanFixture.PLAN_WITH_TRIAL;
            SubscriptionRequest request = new SubscriptionRequest
            {
                PaymentMethodToken = creditCard.Token,
                PlanId = plan.Id,
                MerchantAccountId = MerchantAccountIDs.NON_DEFAULT_MERCHANT_ACCOUNT_ID
            };

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

            Assert.AreEqual(MerchantAccountIDs.NON_DEFAULT_MERCHANT_ACCOUNT_ID, subscription.MerchantAccountId);
        }
开发者ID:zxed,项目名称:braintree_dotnet,代码行数:16,代码来源:SubscriptionTest.cs

示例15: Create_SetId

        public void Create_SetId()
        {
            TestPlan plan = PlanFixture.PLAN_WITH_TRIAL;
            String newId = "new-id-" + new Random().Next(1000000);
            SubscriptionRequest request = new SubscriptionRequest
            {
                PaymentMethodToken = creditCard.Token,
                PlanId = plan.Id,
                Price = 482.48M,
                Id = newId
            };

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

            Assert.AreEqual(newId, subscription.Id);
        }
开发者ID:zxed,项目名称:braintree_dotnet,代码行数:18,代码来源:SubscriptionTest.cs


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