コード例 #1
0
ファイル: Program.cs プロジェクト: NickJosevski/XamarinStripe
        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());
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: NickJosevski/XamarinStripe
        private static void TestCreateInvoiceItems(StripePayment payment)
        {
            StripeCustomer cust = payment.CreateCustomer(new StripeCustomerInfo());
            StripeInvoiceItemInfo info = GetInvoiceItemInfo();
            info.CustomerId = cust.Id;
            StripeInvoiceItem item = payment.CreateInvoiceItem(info);
            StripeInvoiceItemUpdateInfo updateInfo = GetInvoiceItemUpdateInfo();
            updateInfo.Description = "Invoice item: " + Guid.NewGuid().ToString();
            StripeInvoiceItem item2 = payment.UpdateInvoiceItem(item.Id, updateInfo);
            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");
            int total;

            var items = payment.GetInvoiceItems(10, 10, null, out total);
            Console.WriteLine(total);
            payment.DeleteCustomer(cust.Id);
        }