예제 #1
0
        public void Test_CreateProduct()
        {
            // Arrange
            var productFamily = Chargify.GetProductFamilyList().Values.FirstOrDefault();

            // Act
            try
            {
                string productName = "test-product" + Guid.NewGuid().ToString();
                var    newProduct  = Chargify.CreateProduct(productFamily.ID, productName, productName, 5000, 1, IntervalUnit.Month, string.Empty, "This is a test product, please archive");

                // Assert
                Assert.IsNotNull(newProduct);
                Assert.AreEqual(productName, newProduct.Handle);
            }
            catch (ChargifyException cEx)
            {
                Assert.Fail(string.Format("Call failed. {0}, {1}", cEx.ToString(), string.Join(", ", cEx.ErrorMessages.Select(m => m.Message))));
            }
        }
예제 #2
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);
            }
        }
예제 #3
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);
            }
        }