Create() публичный Метод

Create a new account in Recurly
public Create ( ) : void
Результат void
Пример #1
0
        public void CreateAdjustment()
        {
            Account acct = new Account(Factories.GetMockAccountName());
            acct.Create();

            Adjustment a = acct.CreateAdjustment("Charge", 5000, "USD", 1);
            a.Create();

            Assert.IsNotNull(a);
        }
Пример #2
0
        public void LookupMissingInfo()
        {
            Account newAcct = new Account(Factories.GetMockAccountName("Lookup Missing Billing Info"));
            newAcct.Create();

            Assert.Throws(typeof(NotFoundException), delegate
            {
                BillingInfo.Get(newAcct.AccountCode);
            });
        }
Пример #3
0
        public void CloseAccount()
        {
            string s = Factories.GetMockAccountName();
            Account acct = new Account(s);
            acct.Create();

            acct.Close();

            Account getAcct = Account.Get(s);
            Assert.AreEqual(getAcct.State, Recurly.Account.AccountState.closed);
        }
Пример #4
0
        public void CreateAccountWithBillingInfo()
        {
            String a = Factories.GetMockAccountName();

            Account acct = new Account(a, "BI", "User",
                "4111111111111111", DateTime.Now.Month, DateTime.Now.Year + 1);

            acct.Create();

            BillingInfo t = BillingInfo.Get(a);
            Assert.AreEqual(t, acct.BillingInfo);
        }
Пример #5
0
        public void LookupAccount()
        {
            string a = Factories.GetMockAccountName();

            Account newAcct = new Account(a);
            newAcct.Email = "*****@*****.**";
            newAcct.Create();

            Account acct = Account.Get(newAcct.AccountCode);
            Assert.IsNotNull(acct);
            Assert.AreEqual(acct.AccountCode, newAcct.AccountCode);
            Assert.IsNotNullOrEmpty(acct.Email);
        }
Пример #6
0
        public void CreateTransactionExistingAccount()
        {
            String a = Factories.GetMockAccountName();
            Account acct = new Account(a, "New Txn", "User",
                "4111111111111111", DateTime.Now.Month, DateTime.Now.Year + 1);
            acct.Create();

            Transaction t = new Transaction(acct.AccountCode, 3000, "USD");

            t.Create();

            Assert.IsNotNull(t.CreatedAt);
        }
Пример #7
0
        public void ClearBillingInfo()
        {
            string s = Factories.GetMockAccountName("Clear Billing Info");

            Account newAcct = new Account(s,
                "George", "Jefferson", "4111111111111111", DateTime.Now.Month, DateTime.Now.Year + 2);
            newAcct.Create();

            newAcct.ClearBillingInfo();

            Assert.IsNull(newAcct.BillingInfo);
            Account t = Account.Get(s);
            Assert.IsNull(t.BillingInfo);
        }
Пример #8
0
        public void LookupBillingInfo()
        {
            string s = Factories.GetMockAccountName("Update Billing Info");
            Account acct = new Account(s,
                "John", "Doe", "4111111111111111", DateTime.Now.Month, DateTime.Now.Year + 2);
            acct.Create();

            Account a = Account.Get(s);

            Assert.AreEqual(a.BillingInfo.FirstName, "John");
            Assert.AreEqual(a.BillingInfo.LastName, "Doe");
            Assert.AreEqual(a.BillingInfo.ExpirationMonth, DateTime.Now.Month);
            Assert.AreEqual(a.BillingInfo.ExpirationYear, DateTime.Now.Year+2);
        }
Пример #9
0
        public void CreateTransactionExistingAccountNewBillingInfo()
        {
            String a = Factories.GetMockAccountName();
            Account acct = new Account(a, "Change Billing Info", "User",
                "4111111111111111", DateTime.Now.Month, DateTime.Now.Year + 1);
            acct.Create();

            acct.BillingInfo = Factories.NewBillingInfo(acct);

            Transaction t = new Transaction(acct, 5000, "USD");

            t.Create();

            Assert.IsNotNull(t.CreatedAt);
        }
Пример #10
0
        public void ListAdjustmentsCredits()
        {
            Account acct = new Account(Factories.GetMockAccountName());
            acct.Create();

            Adjustment a = acct.CreateAdjustment("Charge", 3456, "USD", 1);
            a.Create();

            a = acct.CreateAdjustment("Credit", -3456, "USD", 1);
            a.Create();

            AdjustmentList adjustments = acct.GetAdjustments(Adjustment.AdjustmentType.credit);
            Assert.IsTrue(adjustments.Count == 1);
            Assert.AreEqual(adjustments[0].UnitAmountInCents, -3456);
        }
Пример #11
0
        public void ListAdjustments()
        {
            Account acct = new Account(Factories.GetMockAccountName());
            acct.Create();

            Adjustment a = acct.CreateAdjustment("Charge", 5000, "USD", 1);
            a.Create();

            a = acct.CreateAdjustment("Credit", -1492, "USD", 1);
            a.Create();

            acct.InvoicePendingCharges();

            AdjustmentList adjustments = acct.GetAdjustments();
            Assert.IsTrue(adjustments.Count == 2);
        }
Пример #12
0
        public void ListAdjustmentsCharges()
        {
            Account acct = new Account(Factories.GetMockAccountName());
            acct.Create();

            Adjustment a = acct.CreateAdjustment("Charge", 1234, "USD", 1);
            a.Create();

            a = acct.CreateAdjustment("Credit", -5678, "USD", 1);
            a.Create();

            acct.InvoicePendingCharges();

            AdjustmentList adjustments = acct.GetAdjustments(Adjustment.AdjustmentType.charge);
            Assert.IsTrue(adjustments.Count == 1);
            Assert.AreEqual(adjustments[0].UnitAmountInCents, 1234);
        }
        public void RedeemCoupon()
        {
            string s = Factories.GetMockCouponCode();
            Coupon c = new Coupon(s, Factories.GetMockCouponName(), 10);
            c.Create();

            string act = Factories.GetMockAccountName();
            Account acct = new Account(act);
            acct.Create();
            Assert.IsNotNull(acct.CreatedAt);

            CouponRedemption cr = acct.RedeemCoupon(s, "USD");
            Thread.Sleep(2000);
            Assert.IsNotNull(cr);
            Assert.AreEqual(cr.Currency, "USD");
            Assert.AreEqual(cr.AccountCode, act);
        }
Пример #14
0
        public void CreateAccountWithParameters()
        {
            Account acct = new Account(Factories.GetMockAccountName());
            acct.Username = "******";
            acct.Email = "*****@*****.**";
            acct.FirstName = "Test";
            acct.LastName = "User";
            acct.CompanyName = "Test Company";
            acct.AcceptLanguage = "en";

            acct.Create();

            Assert.AreEqual(acct.Username, "testuser1");
            Assert.AreEqual(acct.Email, "*****@*****.**");
            Assert.AreEqual(acct.FirstName, "Test");
            Assert.AreEqual(acct.LastName, "User");
            Assert.AreEqual(acct.CompanyName, "Test Company");
            Assert.AreEqual(acct.AcceptLanguage, "en");
        }
        public void ListSuccessfulTransactions()
        {
            for (int x = 0; x < 2; x++)
            {
                String a = Factories.GetMockAccountName();
                Account acct = new Account(a, "New Txn", "User",
                    "4111111111111111", DateTime.Now.Month, DateTime.Now.Year + 1);
                acct.Create();

                Transaction t = new Transaction(acct.AccountCode, 3000 + x, "USD");

                t.Create();

            }

            TransactionList list = TransactionList.GetTransactions(TransactionList.TransactionState.successful);

            Assert.IsTrue(list.Count > 0);
        }
        public void LookupRedemption()
        {
            string s = Factories.GetMockCouponCode();
            Coupon c = new Coupon(s, Factories.GetMockCouponName(), 10);
            c.Create();

            string act = Factories.GetMockAccountName();
            Account acct = new Account(act);
            acct.Create();
            Assert.IsNotNull(acct.CreatedAt);

            CouponRedemption cr = acct.RedeemCoupon(s, "USD");

            Assert.IsNotNull(cr);

            cr = acct.GetActiveCoupon();
            Assert.AreEqual(cr.CouponCode, s);
            Assert.AreEqual(cr.AccountCode, act);
        }
        public void LookupCouponInvoice()
        {
            string s = Factories.GetMockCouponCode();
            Dictionary<string, int> discounts = new Dictionary<string,int>();
            discounts.Add("USD",1000);
            Coupon c = new Coupon(s, Factories.GetMockCouponName(), discounts);
            c.Create();

            string act = Factories.GetMockAccountName();
            Account acct = new Account(s, "John", "Doe", "4111111111111111", DateTime.Now.Month, DateTime.Now.Year + 2);
            acct.Create();

            CouponRedemption cr = acct.RedeemCoupon(s, "USD");

            Transaction t = new Transaction(acct, 5000, "USD");
            t.Create();

            CouponRedemption cr2 = Invoice.Get(t.Invoice.Value).GetCoupon();

            Assert.AreEqual(cr, cr2);
        }
Пример #18
0
        public void UpdateBillingInfo()
        {
            string s = Factories.GetMockAccountName("Update Billing Info");
            Account acct = new Account(s,
                "John","Doe", "4111111111111111", DateTime.Now.Month, DateTime.Now.Year+2);
            acct.Create();

            BillingInfo billingInfo = new BillingInfo(acct);
            billingInfo.FirstName = "Jane";
            billingInfo.LastName = "Smith";
            billingInfo.CreditCardNumber = "4111111111111111";
            billingInfo.ExpirationMonth = DateTime.Now.AddMonths(3).Month;
            billingInfo.ExpirationYear = DateTime.Now.AddYears(3).Year;
            billingInfo.Update();

            Account a = Account.Get(s);

            Assert.AreEqual(a.BillingInfo.FirstName, "Jane");
            Assert.AreEqual(a.BillingInfo.LastName, "Smith");
            Assert.AreEqual(a.BillingInfo.ExpirationMonth, DateTime.Now.AddMonths(3).Month);
            Assert.AreEqual(a.BillingInfo.ExpirationYear, DateTime.Now.AddYears(3).Year);
        }
Пример #19
0
 public void CreateAccount()
 {
     Account acct = new Account(Factories.GetMockAccountName());
     acct.Create();
     Assert.IsNotNull(acct.CreatedAt);
 }
Пример #20
0
        public void UpdateAccount()
        {
            Account acct = new Account(Factories.GetMockAccountName());
            acct.Create();

            acct.LastName = "UpdateTest123";
            acct.Update();

            Account getAcct = Account.Get(acct.AccountCode);
            Assert.AreEqual(acct.LastName, getAcct.LastName);
        }
Пример #21
0
        public void ListCouponsMaxedOut()
        {
            string s = Factories.GetMockCouponCode();
            Coupon c = new Coupon(s, Factories.GetMockCouponName(), 1);
            c.MaxRedemptions = 1;
            c.Create();

            Account t = new Account(Factories.GetMockAccountName("Coupon Redemption Max"));
            t.Create();
            t.RedeemCoupon(s, "USD");

            CouponList list = CouponList.List();
            Assert.IsTrue(list.Count > 1);
        }
Пример #22
0
        public void ReopenAccount()
        {
            string s = Factories.GetMockAccountName();
            Account acct = new Account(s);
            acct.Create();
            acct.Close();

            acct.Reopen();

            Account test = Account.Get(s);
            Assert.AreEqual(acct.State, Recurly.Account.AccountState.active);
            Assert.AreEqual(test.State, Recurly.Account.AccountState.active);
        }
        public void ListTransactionsForAccount()
        {
            String a = Factories.GetMockAccountName();
            Account acct = new Account(a, "New Txn", "User",
                "4111111111111111", DateTime.Now.Month, DateTime.Now.Year + 1);
            acct.Create();

            Transaction t = new Transaction(acct.AccountCode, 3000, "USD");
            t.Create();

            Transaction t2 = new Transaction(acct.AccountCode, 200, "USD");
            t2.Create();

            TransactionList list = acct.GetTransactions();
            Assert.IsTrue(list.Count > 0);
        }
Пример #24
0
        public void ListAdjustmentsPendingToInvoiced()
        {
            Account acct = new Account(Factories.GetMockAccountName());
            acct.Create();

            Adjustment a = acct.CreateAdjustment("Charge", 1234, "USD", 1);
            a.Create();

            a = acct.CreateAdjustment("Credit", -5678, "USD", 1);
            a.Create();

            AdjustmentList adjustments = acct.GetAdjustments(state: Adjustment.AdjustmentState.pending);
            Assert.IsTrue(adjustments.Count == 2);

            acct.InvoicePendingCharges();

            adjustments = acct.GetAdjustments(state: Adjustment.AdjustmentState.invoiced);
            Assert.IsTrue(adjustments.Count == 2);
        }