An account in Recurly. https://dev.recurly.com/docs/get-account
Inheritance: Recurly.RecurlyEntity
        public void ListExpiredSubscriptions()
        {
            String s = Factories.GetMockPlanCode();
            Plan p = new Plan(s, Factories.GetMockPlanName());
            p.Description = "Subscription Test";
            p.PlanIntervalLength = 1;
            p.PlanIntervalUnit = Plan.IntervalUnit.months;
            p.UnitAmountInCents.Add("USD", 400);
            p.Create();

            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);

                Subscription sub = new Subscription(acct, p, "USD");
                sub.StartsAt = DateTime.Now.AddMonths(-5);

                sub.Create();

                Thread.Sleep(1);
            }

            SubscriptionList list = SubscriptionList.GetSubscriptions(Subscription.SubstriptionState.canceled);
            Assert.IsTrue(list.Count > 0);

            p.Deactivate();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new subscription
 /// </summary>
 /// <param name="account"></param>
 /// <param name="plan"></param>
 /// <param name="currency"></param>
 public Subscription(Account account, Plan plan, string currency)
 {
     this._accountCode = account.AccountCode;
     this._account = account;
     this.Plan = plan;
     this.Currency = currency;
     this.Quantity = 1;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a new subscription object
 /// </summary>
 /// <param name="account"></param>
 /// <param name="plan"></param>
 /// <param name="currency"></param>
 public Subscription(Account account, Plan plan, string currency)
 {
     _accountCode = account.AccountCode;
     _account = account;
     Plan = plan;
     Currency = currency;
     Quantity = 1;
 }
Ejemplo n.º 4
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);
            });
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        public void CreateTransactionNewAccount()
        {
            String a = Factories.GetMockAccountName();
            Account acct = new Account(a, "New Txn", "User",
                "4111111111111111", DateTime.Now.Month, DateTime.Now.Year + 1);

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

            t.Create();

            Assert.IsNotNull(t.CreatedAt);
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
0
        public void RefundTransactionFull()
        {
            String a = Factories.GetMockAccountName();
            Account acct = new Account(a, "New Txn", "User",
                "4111111111111111", DateTime.Now.Month, DateTime.Now.Year + 1);

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

            t.Create();

            t.Refund();

            Assert.AreEqual(t.Status, Transaction.TransactionState.voided);
        }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
0
        public void LookupTransaction()
        {
            String a = Factories.GetMockAccountName();
            Account acct = new Account(a, "New Txn", "User",
                "4111111111111111", DateTime.Now.Month, DateTime.Now.Year + 1);

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

            t.Create();

            Transaction t2 = Transaction.Get(t.Uuid);

            Assert.AreEqual(t, t2);
        }
Ejemplo n.º 14
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);
        }
Ejemplo n.º 15
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);
        }
Ejemplo n.º 16
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);
        }
Ejemplo n.º 17
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);
        }
        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 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);
        }
Ejemplo n.º 21
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 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);
        }
Ejemplo n.º 23
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);
        }
        public void ListActiveSubscriptions()
        {
            String s = Factories.GetMockPlanCode();
            Plan p = new Plan(s, Factories.GetMockPlanName());
            p.Description = "Subscription Test";
            p.UnitAmountInCents.Add("USD", 300);
            p.Create();

            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);

                Subscription sub = new Subscription(acct, p, "USD");
                sub.Create();

                Thread.Sleep(1);
            }

            SubscriptionList list = SubscriptionList.GetSubscriptions(Subscription.SubstriptionState.active);
            Assert.IsTrue(list.Count > 0);
            p.Deactivate();
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Lists accounts, limited to state
 /// </summary>
 /// <param name="state">Account state to retrieve</param>
 /// <returns></returns>
 public static RecurlyList<Account> List(Account.AccountState state = Account.AccountState.Active)
 {
     return new AccountList(Account.UrlPrefix + "?state=" + state.ToString().EnumNameToTransportCase());
 }
Ejemplo n.º 26
0
        /// <summary>
        /// Lookup a Recurly account
        /// </summary>
        /// <param name="accountCode"></param>
        /// <returns></returns>
        public static Account Get(string accountCode)
        {
            var account = new Account();
            // GET /accounts/<account code>
            var statusCode = Client.Instance.PerformRequest(Client.HttpRequestMethod.Get,
                UrlPrefix + Uri.EscapeUriString(accountCode),
                account.ReadXml);

            return statusCode == HttpStatusCode.NotFound ? null : account;
        }
Ejemplo n.º 27
0
 public bool Equals(Account account)
 {
     return account != null && AccountCode == account.AccountCode;
 }
Ejemplo n.º 28
0
 public BillingInfo(Account account)
     : this()
 {
     AccountCode = account.AccountCode;
 }
        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);
        }
Ejemplo n.º 30
0
 /// <summary>
 /// Creates a new transaction
 /// </summary>
 /// <param name="account"></param>
 /// <param name="amountInCents"></param>
 /// <param name="currency"></param>
 public Transaction(Account account, int amountInCents, string currency)
 {
     Account = account;
     AmountInCents = amountInCents;
     Currency = currency;
 }