public void Customer_OddCharactersForOrganization()
        {
            // Arrange
            string referenceID = Guid.NewGuid().ToString();
            var    customer    = new Customer()
            {
                FirstName        = Faker.Name.FirstName(),
                LastName         = Faker.Name.LastName(),
                Email            = Faker.Internet.Email(),
                Phone            = Faker.Phone.PhoneNumber(),
                Organization     = "Chargify&",
                SystemID         = referenceID,
                ShippingAddress  = Faker.Address.StreetAddress(false),
                ShippingAddress2 = Faker.Address.SecondaryAddress(),
                ShippingCity     = Faker.Address.City(),
                ShippingState    = Faker.Address.StateAbbr(),
                ShippingZip      = Faker.Address.ZipCode(),
                ShippingCountry  = "US"
            };

            // Act
            var createdCustomer = Chargify.CreateCustomer(customer);

            // Assert
            Assert.IsNotNull(createdCustomer);
            //Assert.IsInstanceOfType(createdCustomer, typeof(Customer));
            Assert.IsTrue(createdCustomer.Organization == customer.Organization);
        }
Example #2
0
        public void Can_enable_billing_portal_access_by_system_Id()
        {
            // Arrange
            string referenceID = Guid.NewGuid().ToString();
            var    customer    = new Customer()
            {
                FirstName        = Faker.Name.FirstName(),
                LastName         = Faker.Name.LastName(),
                Email            = Faker.Internet.Email(),
                Phone            = Faker.Phone.PhoneNumber(),
                Organization     = Faker.Company.CompanyName(),
                SystemID         = referenceID,
                ShippingAddress  = Faker.Address.StreetAddress(false),
                ShippingAddress2 = Faker.Address.SecondaryAddress(),
                ShippingCity     = Faker.Address.City(),
                ShippingState    = Faker.Address.StateAbbr(),
                ShippingZip      = Faker.Address.ZipCode(),
                ShippingCountry  = "US",
                TaxExempt        = true
            };

            // Act
            var createdCustomer = Chargify.CreateCustomer(customer);

            Chargify.RevokeBillingPortalAccess(createdCustomer.ChargifyID);
            Chargify.EnableBillingPortalAccess(createdCustomer.SystemID);

            // Assert
            var managementLink = Chargify.GetManagementLink(createdCustomer.ChargifyID);

            Assert.IsNotNull(managementLink);


            Chargify.DeleteCustomer(createdCustomer.ChargifyID);
        }
Example #3
0
        public void Customer_OddCharactersForOrganization()
        {
            // Arrange
            string referenceID = Guid.NewGuid().ToString();
            var    customer    = new Customer()
            {
                FirstName        = "Scott",
                LastName         = "Pilgrim",
                Email            = "*****@*****.**",
                Phone            = "123-456-7890",
                Organization     = "Chargify&",
                SystemID         = referenceID,
                ShippingAddress  = "Address Line 1",
                ShippingAddress2 = "Address Line 2",
                ShippingCity     = "New York",
                ShippingState    = "New York",
                ShippingZip      = "10001",
                ShippingCountry  = "US"
            };

            // Act
            var createdCustomer = Chargify.CreateCustomer(customer);

            // Assert
            Assert.IsNotNull(createdCustomer);
            //Assert.IsInstanceOfType(createdCustomer, typeof(Customer));
            Assert.IsTrue(createdCustomer.Organization == customer.Organization);
        }
        public void Customer_CreateCustomer()
        {
            // Arrange
            string referenceID = Guid.NewGuid().ToString();
            var    customer    = new Customer()
            {
                FirstName        = Faker.Name.FirstName(),
                LastName         = Faker.Name.LastName(),
                Email            = Faker.Internet.Email(),
                Phone            = Faker.Phone.PhoneNumber(),
                Organization     = Faker.Company.CompanyName(),
                SystemID         = referenceID,
                ShippingAddress  = Faker.Address.StreetAddress(false),
                ShippingAddress2 = Faker.Address.SecondaryAddress(),
                ShippingCity     = Faker.Address.City(),
                ShippingState    = Faker.Address.StateAbbr(),
                ShippingZip      = Faker.Address.ZipCode(),
                ShippingCountry  = "US",
                TaxExempt        = true
            };

            // Act
            var createdCustomer = Chargify.CreateCustomer(customer);

            // Assert
            Assert.IsNotNull(createdCustomer);
            //Assert.IsInstanceOfType(createdCustomer, typeof(Customer));
            Assert.IsTrue(createdCustomer.SystemID == customer.SystemID);
            Assert.IsTrue(createdCustomer.FirstName == customer.FirstName);
            Assert.IsTrue(createdCustomer.LastName == customer.LastName);
            Assert.IsTrue(createdCustomer.Organization == customer.Organization);
            Assert.IsTrue(createdCustomer.Email == customer.Email);
            Assert.IsTrue(createdCustomer.Phone == customer.Phone);
            Assert.IsTrue(createdCustomer.ShippingAddress == customer.ShippingAddress);
            Assert.IsTrue(createdCustomer.ShippingAddress2 == customer.ShippingAddress2);
            Assert.IsTrue(createdCustomer.ShippingCity == customer.ShippingCity);
            Assert.IsTrue(createdCustomer.ShippingState == customer.ShippingState);
            Assert.IsTrue(createdCustomer.ShippingZip == customer.ShippingZip);
            Assert.IsTrue(createdCustomer.ShippingCountry == customer.ShippingCountry);
            Assert.IsTrue(createdCustomer.TaxExempt);

            // Can't cleanup, Chargify doesn't support customer deletions
        }
Example #5
0
        public void Can_revoke_billing_portal_access()
        {
            // Arrange
            string referenceID = Guid.NewGuid().ToString();
            var    customer    = new Customer()
            {
                FirstName        = Faker.Name.FirstName(),
                LastName         = Faker.Name.LastName(),
                Email            = Faker.Internet.Email(),
                Phone            = Faker.Phone.PhoneNumber(),
                Organization     = Faker.Company.CompanyName(),
                SystemID         = referenceID,
                ShippingAddress  = Faker.Address.StreetAddress(false),
                ShippingAddress2 = Faker.Address.SecondaryAddress(),
                ShippingCity     = Faker.Address.City(),
                ShippingState    = Faker.Address.StateAbbr(),
                ShippingZip      = Faker.Address.ZipCode(),
                ShippingCountry  = "US",
                TaxExempt        = true
            };

            // Act
            var createdCustomer = Chargify.CreateCustomer(customer);

            Chargify.RevokeBillingPortalAccess(createdCustomer.ChargifyID);
            // Assert

            try
            {
                Chargify.GetManagementLink(createdCustomer.ChargifyID);
                Assert.Fail("Error was expected, but not received");
            }
            catch (ChargifyException chEx)
            {
                Assert.IsNotNull(chEx.ErrorMessages);
                Assert.AreEqual(1, chEx.ErrorMessages.Count);
                Assert.IsTrue(chEx.ErrorMessages.Any(e => e.Message.Contains("Billing Portal")), $"Found '{string.Join(", ", chEx.ErrorMessages.Select(x => x.Message))}'");
                //todo: Need to run test to find out the exact error message
            }

            Chargify.DeleteCustomer(createdCustomer.ChargifyID);
        }
Example #6
0
        public void Customer_CreateCustomer()
        {
            // Arrange
            string referenceID = Guid.NewGuid().ToString();
            var    customer    = new Customer()
            {
                FirstName        = "Scott",
                LastName         = "Pilgrim",
                Email            = "*****@*****.**",
                Phone            = "123-456-7890",
                Organization     = "Chargify",
                SystemID         = referenceID,
                ShippingAddress  = "Address Line 1",
                ShippingAddress2 = "Address Line 2",
                ShippingCity     = "New York",
                ShippingState    = "New York",
                ShippingZip      = "10001",
                ShippingCountry  = "US"
            };

            // Act
            var createdCustomer = Chargify.CreateCustomer(customer);

            // Assert
            Assert.IsNotNull(createdCustomer);
            //Assert.IsInstanceOfType(createdCustomer, typeof(Customer));
            Assert.IsTrue(createdCustomer.SystemID == customer.SystemID);
            Assert.IsTrue(createdCustomer.FirstName == customer.FirstName);
            Assert.IsTrue(createdCustomer.LastName == customer.LastName);
            Assert.IsTrue(createdCustomer.Organization == customer.Organization);
            Assert.IsTrue(createdCustomer.Email == customer.Email);
            Assert.IsTrue(createdCustomer.Phone == customer.Phone);
            Assert.IsTrue(createdCustomer.ShippingAddress == customer.ShippingAddress);
            Assert.IsTrue(createdCustomer.ShippingAddress2 == customer.ShippingAddress2);
            Assert.IsTrue(createdCustomer.ShippingCity == customer.ShippingCity);
            Assert.IsTrue(createdCustomer.ShippingState == customer.ShippingState);
            Assert.IsTrue(createdCustomer.ShippingZip == customer.ShippingZip);
            Assert.IsTrue(createdCustomer.ShippingCountry == customer.ShippingCountry);

            // Can't cleanup, Chargify doesn't support customer deletions
        }
        public void Customer_CreateWithError()
        {
            // Arrange
            Chargify.UseJSON = true;
            var customer = new Customer()
            {
                FirstName = Faker.Name.FirstName()
            };

            // Act
            try
            {
                Chargify.CreateCustomer(customer);
                Assert.Fail("Error was expected, but not received");
            }
            catch (ChargifyException chEx)
            {
                Assert.IsNotNull(chEx.ErrorMessages);
                Assert.AreEqual(2, chEx.ErrorMessages.Count);
                Assert.IsTrue(chEx.ErrorMessages.Any(e => e.Message == "Last name: cannot be blank."));
                Assert.IsTrue(chEx.ErrorMessages.Any(e => e.Message == "Email address: cannot be blank."));
            }
            Chargify.UseJSON = false;
        }
Example #8
0
        public void Startup()
        {
            int familyId          = int.MinValue;
            var productFamilyList = Chargify.GetProductFamilyList();

            if (productFamilyList.Count == 0)
            {
                var newProductFamilyId = Guid.NewGuid().ToString();
                var newProductFamily   = Chargify.CreateProductFamily(new ProductFamily(newProductFamilyId, newProductFamilyId, null, null));
                familyId = newProductFamily.ID;
            }
            else
            {
                familyId = productFamilyList.FirstOrDefault().Key;
            }

            var productId     = int.MinValue;
            var productHandle = string.Empty;
            var productList   = Chargify.GetProductList();

            if (productList.Count == 0)
            {
                var newProductId = Guid.NewGuid().ToString();
                var newProduct   = Chargify.CreateProduct(familyId, newProductId, newProductId.Replace("-", "_"), 100, 1, IntervalUnit.Month, null, newProductId);
                productId     = newProduct.ID;
                productHandle = newProduct.Handle;
            }
            else
            {
                productId     = productList.FirstOrDefault().Key;
                productHandle = productList.FirstOrDefault().Value.Handle;
            }

            var      customerId   = int.MinValue;
            var      customerList = Chargify.GetCustomerList();
            string   referenceID  = Guid.NewGuid().ToString();
            Customer customer     = null;

            if (customerList.Count == 0)
            {
                var newCustomer = new Customer()
                {
                    FirstName        = Faker.Name.FirstName(),
                    LastName         = Faker.Name.LastName(),
                    Email            = Faker.Internet.Email(),
                    Phone            = Faker.Phone.PhoneNumber(),
                    Organization     = Faker.Company.CompanyName(),
                    SystemID         = referenceID,
                    ShippingAddress  = Faker.Address.StreetAddress(false),
                    ShippingAddress2 = Faker.Address.SecondaryAddress(),
                    ShippingCity     = Faker.Address.City(),
                    ShippingState    = Faker.Address.StateAbbr(),
                    ShippingZip      = Faker.Address.ZipCode(),
                    ShippingCountry  = "US"
                };

                customer   = Chargify.CreateCustomer(newCustomer) as Customer;
                customerId = customer.ChargifyID;
            }
            else
            {
                customer   = customerList.FirstOrDefault().Value as Customer;
                customerId = customer.ChargifyID;
            }

            var subscriptionList = Chargify.GetSubscriptionList();

            if (subscriptionList.Count == 0)
            {
                var expMonth        = DateTime.Now.AddMonths(1).Month;
                var expYear         = DateTime.Now.AddMonths(12).Year;
                var newPaymentInfo  = GetTestPaymentMethod(customer);
                var newSubscription = Chargify.CreateSubscription(productHandle, customer.ChargifyID, newPaymentInfo);
            }
        }
Example #9
0
        public void Startup()
        {
            int familyId          = int.MinValue;
            var productFamilyList = Chargify.GetProductFamilyList();

            if (productFamilyList.Count == 0)
            {
                var newProductFamilyId = Guid.NewGuid().ToString();
                var newProductFamily   = Chargify.CreateProductFamily(new ProductFamily(newProductFamilyId, newProductFamilyId, null, null));
                familyId = newProductFamily.ID;
            }
            else
            {
                familyId = productFamilyList.FirstOrDefault().Key;
            }

            var productId     = int.MinValue;
            var productHandle = string.Empty;
            var productList   = Chargify.GetProductList();

            if (productList.Count == 0)
            {
                var newProductId = Guid.NewGuid().ToString();
                var newProduct   = Chargify.CreateProduct(familyId, newProductId, newProductId.Replace("-", "_"), 100, 1, IntervalUnit.Month, null, newProductId);
                productId     = newProduct.ID;
                productHandle = newProduct.Handle;
            }
            else
            {
                productId     = productList.FirstOrDefault().Key;
                productHandle = productList.FirstOrDefault().Value.Handle;
            }

            var      customerId   = int.MinValue;
            var      customerList = Chargify.GetCustomerList();
            string   referenceID  = Guid.NewGuid().ToString();
            Customer customer     = null;

            if (customerList.Count == 0)
            {
                var newCustomer = new Customer()
                {
                    FirstName        = "Scott",
                    LastName         = "Pilgrim",
                    Email            = "*****@*****.**",
                    Phone            = "123-456-7890",
                    Organization     = "Chargify",
                    SystemID         = referenceID,
                    ShippingAddress  = "Address Line 1",
                    ShippingAddress2 = "Address Line 2",
                    ShippingCity     = "New York",
                    ShippingState    = "New York",
                    ShippingZip      = "10001",
                    ShippingCountry  = "US"
                };

                customer   = Chargify.CreateCustomer(newCustomer) as Customer;
                customerId = customer.ChargifyID;
            }
            else
            {
                customer   = customerList.FirstOrDefault().Value as Customer;
                customerId = customer.ChargifyID;
            }

            var subscriptionList = Chargify.GetSubscriptionList();

            if (subscriptionList.Count == 0)
            {
                var expMonth        = DateTime.Now.AddMonths(1).Month;
                var expYear         = DateTime.Now.AddMonths(12).Year;
                var newPaymentInfo  = GetTestPaymentMethod(customer);
                var newSubscription = Chargify.CreateSubscription(productHandle, customer.ChargifyID, newPaymentInfo);
            }
        }