Exemple #1
0
        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"
            });

            var           invoices = payment.GetInvoices(0, 10, cust.ID);
            StripeInvoice upcoming = payment.GetUpcomingInvoice(cust.ID);

            payment.Unsubscribe(cust.ID, true);
            payment.DeletePlan(planInfo.ID);
            foreach (StripeLineItem line in upcoming)
            {
                Console.WriteLine("{0} for type {1}", line.Amount, line.GetType());
            }
        }
Exemple #2
0
        static void TestCreateInvoiceItems(StripePayment payment)
        {
            StripeCustomer        cust = payment.CreateCustomer(new StripeCustomerInfo());
            StripeInvoiceItemInfo info = GetInvoiceItemInfo();

            info.CustomerID = cust.ID;
            StripeInvoiceItem     item    = payment.CreateInvoiceItem(info);
            StripeInvoiceItemInfo newInfo = GetInvoiceItemInfo();

            newInfo.Description = "Invoice item: " + Guid.NewGuid().ToString();
            StripeInvoiceItem item2 = payment.UpdateInvoiceItem(item.ID, newInfo);
            StripeInvoiceItem item3 = payment.GetInvoiceItem(item2.ID);

            if (item.Description == item3.Description)
            {
                throw new Exception("Update failed");
            }
            StripeInvoiceItem deleted = payment.DeleteInvoiceItem(item2.ID);

            if (!deleted.Deleted.HasValue && deleted.Deleted.Value)
            {
                throw new Exception("Delete failed");
            }
            var items = payment.GetInvoiceItems(10, 10, null);

            Console.WriteLine(items.Total);
            payment.DeleteCustomer(cust.ID);
        }