public void CreatePlan() { Plan p = new Plan(Factories.GetMockPlanCode(), Factories.GetMockPlanName()); p.SetupFeeInCents.Add("USD",500); p.AccountingCode = "accountingcode123"; p.Description = "a test plan"; p.DisplayDonationAmounts = true; p.DisplayPhoneNumber = false; p.DisplayQuantity = true; p.TotalBillingCycles = 5; p.TrialIntervalUnit = Plan.IntervalUnit.months; p.TrialIntervalLength = 1; p.PlanIntervalUnit = Plan.IntervalUnit.days; p.PlanIntervalLength = 180; p.Create(); Assert.IsNotNull(p.CreatedAt); Assert.AreEqual(p.AccountingCode, "accountingcode123"); Assert.AreEqual(p.Description, "a test plan"); Assert.IsTrue(p.DisplayDonationAmounts.Value); Assert.IsFalse(p.DisplayPhoneNumber.Value); Assert.IsTrue(p.DisplayQuantity.Value); Assert.AreEqual(p.TotalBillingCycles, 5); Assert.AreEqual(p.TrialIntervalUnit, Plan.IntervalUnit.months); Assert.AreEqual(p.TrialIntervalLength, 1); Assert.AreEqual(p.PlanIntervalUnit, Plan.IntervalUnit.days); Assert.AreEqual(p.PlanIntervalLength, 180); p.Deactivate(); }
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(); }
/// <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; }
/// <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; }
public void CreatePlanSmall() { Plan p = new Plan(Factories.GetMockPlanCode(), Factories.GetMockPlanName()); p.SetupFeeInCents.Add("USD",100); p.Create(); Assert.IsNotNull(p.CreatedAt); Assert.AreEqual(p.SetupFeeInCents["USD"], 100); p.Deactivate(); }
public void ListPlans() { Plan p = new Plan(Factories.GetMockPlanCode(), Factories.GetMockPlanName()); p.SetupFeeInCents.Add("USD", 100); p.Create(); p = new Plan(Factories.GetMockPlanCode(), Factories.GetMockPlanName()); p.SetupFeeInCents.Add("USD", 200); p.Create(); PlanList l = PlanList.GetPlans(); Assert.IsTrue(l.Count > 1); }
public void CreateCouponPlan() { Plan p = new Plan(Factories.GetMockPlanCode("coupon plan"), "Coupon Test"); p.SetupFeeInCents.Add("USD", 500); p.UnitAmountInCents.Add("USD", 5000); p.Create(); string s = Factories.GetMockCouponCode(); Coupon c = new Coupon(s, Factories.GetMockCouponName(), new Dictionary<string, int>()); c.DiscountInCents.Add("USD", 100); c.Plans.Add(p.PlanCode); p.Deactivate(); }
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(); }
public void DeactivatePlan() { String s = Factories.GetMockPlanCode(); Plan p = new Plan(s, Factories.GetMockPlanName()); p.Description = "Test Delete"; p.UnitAmountInCents.Add("USD", 100); p.Create(); p = Plan.Get(s); Assert.IsNotNull(p.CreatedAt); Assert.AreEqual(p.UnitAmountInCents["USD"], 100); p.Deactivate(); try { Plan p2 = Plan.Get(s); Assert.Fail("Plan has not been deactivated."); } catch (Exception) { // Expected } }
public bool Equals(Plan plan) { return this.PlanCode == plan.PlanCode; }
public void ListForAccount() { String s = Factories.GetMockPlanCode(); Plan p = new Plan(s, Factories.GetMockPlanName()); p.Description = "Subscription Test"; p.UnitAmountInCents.Add("USD", 400); p.Create(); String s2 = Factories.GetMockPlanCode(); Plan p2 = new Plan(s2, Factories.GetMockPlanName()); p2.Description = "Subscription Test"; p2.UnitAmountInCents.Add("USD", 500); p2.Create(); 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(); Subscription sub2 = new Subscription(acct, p2, "USD"); sub2.Create(); SubscriptionList list = acct.GetSubscriptions(Subscription.SubstriptionState.all); Assert.IsTrue(list.Count > 0); p.Deactivate(); p2.Deactivate(); }
/// <summary> /// Retrieves a Plan /// </summary> /// <param name="planCode"></param> /// <returns></returns> public static Plan Get(string planCode) { var plan = new Plan(); var statusCode = Client.Instance.PerformRequest(Client.HttpRequestMethod.Get, Plan.UrlPrefix + Uri.EscapeUriString(planCode), plan.ReadXml); return statusCode == HttpStatusCode.NotFound ? null : plan; }
/// <summary> /// Retrieves a Plan /// </summary> /// <param name="planCode"></param> /// <returns></returns> public static Plan Get(string planCode) { Plan plan = new Plan(); HttpStatusCode statusCode = Client.PerformRequest(Client.HttpRequestMethod.Get, UrlPrefix + System.Uri.EscapeUriString(planCode), new Client.ReadXmlDelegate(plan.ReadXml)); if (statusCode == HttpStatusCode.NotFound) return null; return plan; }
public void LookupPlan() { String s = Factories.GetMockPlanCode(); Plan p = new Plan(s, Factories.GetMockPlanName()); p.Description = "Test Lookup"; p.UnitAmountInCents.Add("USD", 100); p.Create(); Plan l = Plan.Get(s); Assert.IsNotNull(l.CreatedAt); Assert.AreEqual(l.UnitAmountInCents["USD"], 100); Assert.AreEqual(l.PlanCode, s); Assert.AreEqual(l.Description, "Test Lookup"); p.Deactivate(); }
public void UpdatePlan() { String s = Factories.GetMockPlanCode(); Plan p = new Plan(s, Factories.GetMockPlanName()); p.Description = "Test Update"; p.UnitAmountInCents.Add("USD", 100); p.Create(); p.UnitAmountInCents["USD"] = 5000; p.SetupFeeInCents.Add("USD", 100); p.Update(); p = Plan.Get(s); Assert.AreEqual(p.UnitAmountInCents["USD"], 5000); Assert.AreEqual(p.SetupFeeInCents["USD"], 100); p.Deactivate(); }
public bool Equals(Plan plan) { return(PlanCode == plan.PlanCode); }