Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for latest_invoice on Subscription #1545

Merged
merged 1 commit into from
Feb 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ environment:
COVERALLS_REPO_TOKEN:
secure: T0PmP8uyzCseacBCDRBlti2y9Tz5DL6fknea0MKWvbPYrzADmLY2/5kOTfYIsPUk
# If you bump this, don't forget to bump `MinimumMockVersion` in `StripeMockFixture.cs` as well.
STRIPE_MOCK_VERSION: 0.45.0
STRIPE_MOCK_VERSION: 0.47.0

deploy:
- provider: NuGet
Expand Down
22 changes: 22 additions & 0 deletions src/Stripe.net/Entities/Subscriptions/Subscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,28 @@ internal object InternalDefaultSource
[JsonProperty("items")]
public StripeList<SubscriptionItem> Items { get; set; }

#region Expandable LatestInvoice
[JsonIgnore]
public string LatestInvoiceId { get; set; }

[JsonIgnore]
public Invoice LatestInvoice { get; set; }

[JsonProperty("latest_invoice")]
internal object InternalLatestInvoice
{
get
{
return this.LatestInvoice ?? (object)this.LatestInvoiceId;
}

set
{
StringOrObject<Invoice>.Map(value, s => this.LatestInvoiceId = s, o => this.LatestInvoice = o);
}
}
#endregion

[JsonProperty("livemode")]
public bool Livemode { get; set; }

Expand Down
4 changes: 4 additions & 0 deletions src/StripeTests/Entities/Subscriptions/SubscriptionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public void DeserializeWithExpansions()
string[] expansions =
{
"customer",
"latest_invoice",
};

string json = this.GetFixture("/v1/subscriptions/sub_123", expansions);
Expand All @@ -39,6 +40,9 @@ public void DeserializeWithExpansions()

Assert.NotNull(subscription.Customer);
Assert.Equal("customer", subscription.Customer.Object);

Assert.NotNull(subscription.LatestInvoice);
Assert.Equal("invoice", subscription.LatestInvoice.Object);
}
}
}
2 changes: 1 addition & 1 deletion src/StripeTests/StripeMockFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class StripeMockFixture : IDisposable
/// <remarks>
/// If you bump this, don't forget to bump `STRIPE_MOCK_VERSION` in `appveyor.yml` as well.
/// </remarks>
private const string MockMinimumVersion = "0.45.0";
private const string MockMinimumVersion = "0.47.0";

private readonly string origApiBase;
private readonly string origFilesBase;
Expand Down