예제 #1
0
        public StripeSubscription Subscribe(string customerId, StripeSubscriptionInfo subscription)
        {
            StringBuilder str = UrlEncode(subscription);
            string        ep  = string.Format(subscription_path, api_endpoint, HttpUtility.UrlEncode(customerId));

            return(DoRequest <StripeSubscription> (ep, "POST", str.ToString()));
        }
예제 #2
0
        public StripeSubscription Subscribe(string customerId, StripeSubscriptionInfo subscription)
        {
            StringBuilder str  = UrlEncode(subscription);
            string        ep   = string.Format(subscription_path, api_endpoint, HttpUtility.UrlEncode(customerId));
            string        json = DoRequest(ep, "POST", str.ToString());

            return(JsonConvert.DeserializeObject <StripeSubscription> (json));
        }
예제 #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());
            }
        }
예제 #4
0
 public StripeSubscription Subscribe(string customerId, StripeSubscriptionInfo subscription)
 {
     StringBuilder str = UrlEncode (subscription);
     string ep = string.Format (subscription_path, api_endpoint, HttpUtility.UrlEncode (customerId));
     string json = DoRequest (ep, "POST", str.ToString ());
     return JsonConvert.DeserializeObject<StripeSubscription> (json);
 }
예제 #5
0
        public StripeSubscription UpdateCustomerSubscription(string customer_id, StripeSubscriptionInfo subscription)
        {
            if (String.IsNullOrEmpty(customer_id))
                throw new ArgumentNullException("customer_id");

            StringBuilder str = new StringBuilder();
            subscription.UrlEncode(str);
            if (str.Length > 0)
                str.Length--;

            string ep = String.Format("{0}/customers/{1}/subscription", api_endpoint, HttpUtility.UrlEncode(customer_id));
            string json = DoRequest(ep, "POST", str.ToString());
            return JsonConvert.DeserializeObject<StripeSubscription>(json);
        }
예제 #6
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);
        }