public static async Task <string> RequiredInvoice(string subscriptionId) { StripeConfiguration.SetApiKey("sk_test_5nCTR2UZmnOPWgZASvirbYDy"); StripeInvoiceService invoiceService = new StripeInvoiceService(); StripeList <StripeInvoice> invoiceItems = await invoiceService.ListAsync( new StripeInvoiceListOptions() { SubscriptionId = subscriptionId } ); StripeInvoice value = invoiceItems.First <StripeInvoice>(); return(value.Id); }
public async Task <IHttpActionResult> GetInvoicesAsync(string id, string before = null, string after = null, int limit = 12) { if (!Settings.Current.EnableBilling) { return(NotFound()); } var organization = await GetModelAsync(id); if (organization == null) { return(NotFound()); } if (String.IsNullOrWhiteSpace(organization.StripeCustomerId)) { return(Ok(new List <InvoiceGridModel>())); } if (!String.IsNullOrEmpty(before) && !before.StartsWith("in_")) { before = "in_" + before; } if (!String.IsNullOrEmpty(after) && !after.StartsWith("in_")) { after = "in_" + after; } var invoiceService = new StripeInvoiceService(Settings.Current.StripeApiKey); var invoiceOptions = new StripeInvoiceListOptions { CustomerId = organization.StripeCustomerId, Limit = limit + 1, EndingBefore = before, StartingAfter = after }; var invoices = (await MapCollectionAsync <InvoiceGridModel>(await invoiceService.ListAsync(invoiceOptions), true)).ToList(); return(OkWithResourceLinks(invoices.Take(limit).ToList(), invoices.Count > limit, i => i.Id)); }