public ActionResult Customer(string id) { SetCustomerId(id); Stripe.StripeCustomerService customerService = new Stripe.StripeCustomerService(); customerService.ApiKey = ConfigHelper.GetStripeApiKey(); Stripe.StripeCustomer customer = customerService.Get(id); //Stripe.StripeInvoiceService invoiceService=new Stripe.StripeInvoiceService(); //invoiceService.ApiKey="sk_test_TMvswfMKVJpGk3K1WJ4jGyGL"; //List<Stripe.StripeInvoice> stripeInvoices = invoiceService.List(new Stripe.StripeInvoiceListOptions { CustomerId = id }).ToList(); Stripe.StripeInvoiceItemService invoiceItemService = new Stripe.StripeInvoiceItemService(); invoiceItemService.ApiKey = ConfigHelper.GetStripeApiKey(); List <Stripe.StripeInvoiceLineItem> invoices = invoiceItemService.List(new Stripe.StripeInvoiceItemListOptions { CustomerId = id }).ToList(); MeteredInvoiceViewModel viewModel = new MeteredInvoiceViewModel(); viewModel.Invoices = invoices; viewModel.AzureUsage = GetAzureDataUsage(); viewModel.AzureUsage.StripeCustomerId = id; return(View(viewModel)); }
public ActionResult CreateInvoice(string id) { AzureUsage usage = GetAzureDataUsage(); usage.StripeCustomerId = id; Stripe.StripeInvoiceItemService invoiceItemService = new Stripe.StripeInvoiceItemService(); invoiceItemService.ApiKey = ConfigHelper.GetStripeApiKey(); invoiceItemService.Create(new Stripe.StripeInvoiceItemCreateOptions { Amount = usage.TotalAmount * 100, Currency = "usd", CustomerId = id, Description = usage.Description, }); Response.Redirect(Url.RouteUrl(new { controller = "Metered", action = "Customer", id = id })); return(View()); }