Esempio n. 1
0
        public StripePlan CreatePlan(StripePlanInfo plan)
        {
            if (plan == null)
            {
                throw new ArgumentNullException("plan");
            }
            StringBuilder str = UrlEncode(plan);

            string ep = string.Format("{0}/plans", api_endpoint);

            return(DoRequest <StripePlan> (ep, "POST", str.ToString()));
        }
Esempio n. 2
0
        public StripePlan CreatePlan(StripePlanInfo plan)
        {
            if (plan == null)
            {
                throw new ArgumentNullException("plan");
            }
            StringBuilder str = UrlEncode(plan);

            string ep   = string.Format("{0}/plans", api_endpoint);
            string json = DoRequest(ep, "POST", str.ToString());

            return(JsonConvert.DeserializeObject <StripePlan> (json));
        }
Esempio n. 3
0
        private static void TestInvoices2(StripePayment payment)
        {
            StripeCustomer cust = payment.GetCustomer("cus_ulcOcy5Seu2dpq");
            StripePlanInfo planInfo = new StripePlanInfo
                {
                    Amount = 1999,
                    Id = "testplan",
                    Interval = StripePlanInterval.month,
                    Name = "The Test Plan",
                    //TrialPeriod = 7
                };
            //payment.DeletePlan (planInfo.Id);
            StripePlan plan = payment.CreatePlan(planInfo);
            StripeSubscriptionInfo subInfo = new StripeSubscriptionInfo
                { Card = GetCC(), Plan = planInfo.Id, Prorate = true };
            StripeSubscription sub = payment.Subscribe(cust.Id, subInfo);
            payment.CreateInvoiceItem(
                new StripeInvoiceItemInfo { CustomerId = cust.Id, Amount = 1337, Description = "Test single charge" });

            int total;
            List<StripeInvoice> invoices = payment.GetInvoices(0, 10, cust.Id, out total);
            StripeInvoice upcoming = payment.GetUpcomingInvoice(cust.Id);
            payment.Unsubscribe(cust.Id, true);
            payment.DeletePlan(planInfo.Id);
            foreach (StripeInvoiceLineItem line in upcoming)
            {
                Console.WriteLine("{0} for type {1}", line.Amount, line.GetType());
            }
        }
Esempio n. 4
0
        public StripePlan CreatePlan(StripePlanInfo plan)
        {
            if (plan == null)
                throw new ArgumentNullException ("plan");
            StringBuilder str = UrlEncode (plan);

            string ep = string.Format ("{0}/plans", api_endpoint);
            string json = DoRequest (ep, "POST", str.ToString ());
            return JsonConvert.DeserializeObject<StripePlan> (json);
        }
Esempio n. 5
0
        public void Invoices2()
        {
            var customerJustCreated = _payment.CreateCustomer(new StripeCustomerInfo());

            var cust = _payment.GetCustomer(customerJustCreated.Id);
            var planInfo = new StripePlanInfo
            {
                Amount = 2048,
                Id = "testplan" + DateTime.Now.Ticks,
                Interval = StripePlanInterval.month,
                Name = "The Test Plan",
                //TrialPeriod = 7
            };

            StripePlan plan = _payment.CreatePlan(planInfo);
            StripeSubscriptionInfo subInfo = new StripeSubscriptionInfo { Card = GetValidCreditCard(), Plan = planInfo.Id, Prorate = true };
            StripeSubscription sub = _payment.Subscribe(cust.Id, subInfo);
            _payment.CreateInvoiceItem(
                new StripeInvoiceItemInfo { CustomerId = cust.Id, Amount = 1337, Description = "Test single charge" });

            int total;
            List<StripeInvoice> invoices = _payment.GetInvoices(0, 10, cust.Id, out total);
            Assert.IsNotEmpty(invoices);

            StripeInvoice upcoming = _payment.GetUpcomingInvoice(cust.Id);
            _payment.Unsubscribe(cust.Id, true);
            foreach (StripeInvoiceLineItem line in upcoming)
            {
                Console.WriteLine("{0} for type {1}", line.Amount, line.GetType());
            }

            _payment.DeletePlan(planInfo.Id);
        }