Пример #1
0
        public void TestCustomers()
        {
            // SUBSCRIBE

            // Arrange
            ICustomerEntity customer = CreateMockCustomer();

            // Act
            StripeManager.CreateCustomer(customer);

            // Assert
            Assert.IsNotNull(customer.PaymentSystemId);

            // RETRIEVE

            // Act
            StripeCustomer stripeCustomer = StripeManager.RetrieveCustomer(customer);

            // Assert
            Assert.IsNotNull(stripeCustomer);

            // UPDATE

            // Arrange
            customer.Email = "*****@*****.**";

            // act
            StripeCustomer updatedStripeCustomer = StripeManager.UpdateCustomer(customer);

            // Assert
            Assert.IsNotNull(updatedStripeCustomer);
        }
Пример #2
0
        public void TestChargeWithCustomer()
        {
            // Arrange
            ICustomerEntity customer = CreateMockCustomer();
            IChargeEntity   charge   = CreateMockCharge();

            StripeToken token = CreateTestToken(customer);

            StripeManager.CreateCustomer(customer, token.Id);

            // Act - charge customer
            string chargeId = StripeManager.Charge(customer, charge);

            Assert.IsNotNull(chargeId);

            chargeId = StripeManager.Charge(customer, 12.34f, "Test charge with customer");
            Assert.IsNotNull(chargeId);
        }
Пример #3
0
        public void TestSubscriptions()
        {
            // Arrange
            EnsureTestPlansDeleted();

            // NOTE: Due to the reliance on the API, we must create these for real
            IPlanEntity planA = CreateMockPlanA();

            StripeManager.CreatePlan(planA);

            ICustomerEntity customer = CreateMockCustomer();

            StripeManager.CreateCustomer(customer);

            ISubscriptionEntity subscription = CreateMockSubscription();

            // CREATE
            // Subscribe

            // Act
            StripeSubscription newSub = StripeManager.Subscribe(customer, subscription, planA);

            Assert.IsNotNull(newSub);

            // CHANGE
            // ChangeSubscriptionPlan

            IPlanEntity planB = CreateMockPlanB();

            StripeManager.CreatePlan(planB);

            StripeSubscription changedSub = StripeManager.ChangeSubscriptionPlan(customer, subscription, planB);

            Assert.IsNotNull(changedSub);

            // DELETE
            StripeSubscription cancelledSub = StripeManager.Unsubscribe(customer, subscription);

            Assert.IsNotNull(cancelledSub);
            Assert.IsTrue(cancelledSub.Status == "canceled");
        }