-
Notifications
You must be signed in to change notification settings - Fork 572
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1214 from stripe/remi-invoice-upcoming-add-invoic…
…eitems Upcoming now has `invoice_items` and subscription_billing_cycle_anchor`
- Loading branch information
Showing
3 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
src/Stripe.Tests.XUnit/invoices/retrieving_upcoming_invoice.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Stripe.Tests.Xunit | ||
{ | ||
public class retrieving_upcoming_invoice | ||
{ | ||
public StripeInvoice InvoiceUpcoming { get; } | ||
|
||
public retrieving_upcoming_invoice() | ||
{ | ||
var customerService = new StripeCustomerService(Cache.ApiKey); | ||
var invoiceItemService = new StripeInvoiceItemService(Cache.ApiKey); | ||
var invoiceService = new StripeInvoiceService(Cache.ApiKey); | ||
|
||
var CustomerCreateOptions = new StripeCustomerCreateOptions | ||
{ | ||
SourceToken = "tok_visa", | ||
}; | ||
var Customer = customerService.Create(CustomerCreateOptions); | ||
|
||
var InvoiceItemCreateOptions = new StripeInvoiceItemCreateOptions | ||
{ | ||
Amount = 1000, | ||
Currency = "usd", | ||
CustomerId = Customer.Id | ||
}; | ||
var InvoiceItem = invoiceItemService.Create(InvoiceItemCreateOptions); | ||
|
||
var UpcomingInvoiceOptions = new StripeUpcomingInvoiceOptions | ||
{ | ||
InvoiceItems = new List<StripeInvoiceUpcomingInvoiceItemOption> { | ||
new StripeInvoiceUpcomingInvoiceItemOption { | ||
Amount = 1001, | ||
Currency = "usd", | ||
}, | ||
new StripeInvoiceUpcomingInvoiceItemOption { | ||
Amount = 1002, | ||
InvoiceItemId = InvoiceItem.Id, | ||
}, | ||
}, | ||
}; | ||
InvoiceUpcoming = invoiceService.Upcoming(Customer.Id, UpcomingInvoiceOptions); | ||
} | ||
|
||
[Fact] | ||
public void invoice_upcoming_has_correct_information() | ||
{ | ||
InvoiceUpcoming.Should().NotBeNull(); | ||
InvoiceUpcoming.StripeInvoiceLineItems.Should().NotBeNull(); | ||
InvoiceUpcoming.StripeInvoiceLineItems.Data.Count.Should().Be(2); | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/Stripe.net/Services/Invoices/StripeInvoiceUpcomingInvoiceItemOption.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
|
||
namespace Stripe | ||
{ | ||
public class StripeInvoiceUpcomingInvoiceItemOption : INestedOptions | ||
{ | ||
[JsonProperty("amount")] | ||
public int Amount { get; set; } | ||
|
||
[JsonProperty("currency")] | ||
public string Currency { get; set; } | ||
|
||
[JsonProperty("description")] | ||
public string Description { get; set; } | ||
|
||
[JsonProperty("discountable")] | ||
public bool Discountable { get; set; } | ||
|
||
[JsonProperty("invoiceitem")] | ||
public string InvoiceItemId { get; set; } | ||
|
||
[JsonProperty("metadata")] | ||
public Dictionary<string, string> Metadata { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters