コード例 #1
0
        public void UpgradeSubscription_ChargesProRatadAmount()
        {
            var subscriberHelper = new SubscriberHelper(TestConstants.TestSiteName, TestConstants.TestApiKey);

            var subscriber = new Subscriber
            {
                CustomerId = TestConstants.TestCustomerId,
                ScreenName = TestConstants.TestCustomerId,
                Email = "*****@*****.**"
            };
            var creditCard = new CreditCard
            {
                CardType = "visa",
                ExpirationMonth = 12,
                ExpirationYear = 2012,
                FirstName = "Tester",
                LastName = "Testing",
                Number = TestConstants.ValidCard,
                VerificationValue = "123"
            };

            subscriberHelper.SubscribeToSubscriptionPlanWithCreditCard(subscriber,
                                                                       TestConstants.MediumSubscriptionPlanId,
                                                                       creditCard);
            var upgradeInvoice = subscriberHelper.ChangeSubscriberFeatureLevelWithOnFilePayment(subscriber, TestConstants.HighSubscriptionPlanId);

            Assert.AreEqual(15, upgradeInvoice.Amount.Value);
        }
コード例 #2
0
        public void CreateSubscription_WithHelper_ReturnsInvoice()
        {
            var subscriberHelper = new SubscriberHelper(TestConstants.TestSiteName, TestConstants.TestApiKey);
            var subscriber = new Subscriber
            {
                CustomerId = TestConstants.TestCustomerId,
                ScreenName = TestConstants.TestCustomerId,
                Email = "*****@*****.**"
            };
            var creditCard = new CreditCard
            {
                CardType = "visa",
                ExpirationMonth = 12,
                ExpirationYear = 2012,
                FirstName = "Tester",
                LastName = "Testing",
                Number = TestConstants.ValidCard,
                VerificationValue = "123"
            };

            var invoice = subscriberHelper.SubscribeToSubscriptionPlanWithCreditCard(subscriber, TestConstants.MediumSubscriptionPlanId, creditCard);

            Assert.NotNull(invoice);
        }
コード例 #3
0
        public void DowngradeSubscription_GivesStoreCreditToSubscriber()
        {
            var subscriberHelper = new SubscriberHelper(TestConstants.TestSiteName, TestConstants.TestApiKey);
            var subscriber = new Subscriber
            {
                CustomerId = TestConstants.TestCustomerId,
                ScreenName = TestConstants.TestCustomerId,
                Email = "*****@*****.**"
            };
            var creditCard = new CreditCard
            {
                CardType = "visa",
                ExpirationMonth = 12,
                ExpirationYear = 2012,
                FirstName = "Tester",
                LastName = "Testing",
                Number = TestConstants.ValidCard,
                VerificationValue = "123"
            };

            subscriberHelper.SubscribeToSubscriptionPlanWithCreditCard(subscriber, TestConstants.HighSubscriptionPlanId, creditCard);
            subscriberHelper.ChangeSubscriberFeatureLevelWithOnFilePayment(subscriber, TestConstants.LowSubscriptionPlanId);
            var downgradedSubscriber = subscriberHelper.FetchSubscriber(subscriber.CustomerId);

            Assert.GreaterOrEqual(downgradedSubscriber.StoreCredit.Value, 0);
        }
コード例 #4
0
        public void CreateSubscription_WithHelper_ForFreeSubscriptionPlan_ThrowsForbiddenActionException()
        {
            var subscriberHelper = new SubscriberHelper(TestConstants.TestSiteName, TestConstants.TestApiKey);
            var subscriber = new Subscriber
            {
                CustomerId = TestConstants.TestCustomerId,
                ScreenName = TestConstants.TestCustomerId,
                Email = "*****@*****.**"
            };
            var creditCard = new CreditCard
            {
                CardType = "visa",
                ExpirationMonth = 12,
                ExpirationYear = 2012,
                FirstName = "Tester",
                LastName = "Testing",
                Number = TestConstants.ValidCard,
                VerificationValue = "123"
            };

            var invoice = subscriberHelper.SubscribeToSubscriptionPlanWithCreditCard(subscriber, TestConstants.FreePlanSubscriptionPlanId, creditCard);
        }
コード例 #5
0
        public void CreateSubscription_WithHelper_WhenGatewayTimesout_ThrowsPaymentGatewayTimeoutException()
        {
            var subscriberHelper = new SubscriberHelper(TestConstants.TestSiteName, TestConstants.TestApiKey);
            var subscriber = new Subscriber
            {
                CustomerId = TestConstants.TestCustomerId,
                ScreenName = TestConstants.TestCustomerId,
                Email = "*****@*****.**"
            };
            var creditCard = new CreditCard
            {
                CardType = "visa",
                ExpirationMonth = 12,
                ExpirationYear = 2012,
                FirstName = "Tester",
                LastName = "Testing",
                Number = TestConstants.GatewayUnavailableCard,
                VerificationValue = "123"
            };

            var invoice = subscriberHelper.SubscribeToSubscriptionPlanWithCreditCard(subscriber, TestConstants.MediumSubscriptionPlanId, creditCard);
        }