Skip to content

Commit

Permalink
Add CollectionMethod for Invoices and Subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
cjavilla-stripe committed Jul 2, 2019
1 parent 3fbfdce commit abc7011
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 23 deletions.
7 changes: 7 additions & 0 deletions src/Stripe.net/Entities/InvoiceItems/InvoiceItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ public Subscription Subscription
[JsonProperty("tax_rates")]
public List<TaxRate> TaxRates { get; set; }

/// <summary>
/// Set to <c>true</c> if we grouped proration items into one,
/// <c>false</c> if not.
/// </summary>
[JsonProperty("unified_proration")]
public bool UnifiedProration { get; set; }

[JsonProperty("unit_amount")]
public long? UnitAmount { get; set; }
}
Expand Down
17 changes: 13 additions & 4 deletions src/Stripe.net/Entities/Invoices/Invoice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,10 @@ public class Invoice : StripeEntity<Invoice>, IHasId, IHasMetadata, IHasObject
public bool AutoAdvance { get; set; }

/// <summary>
/// One of <see cref="Billing" />. When charging automatically, Stripe will attempt to pay
/// this subscription at the end of the cycle using the default source attached to the
/// customer. When sending an invoice, Stripe will email your customer an invoice with
/// payment instructions.
/// This field has been renamed to <c>CollectionMethod</c> and will be removed
/// in a future API version.
/// </summary>
[Obsolete("Use CollectionMethod")]
[JsonProperty("billing")]
public Billing? Billing { get; set; }

Expand All @@ -83,6 +82,16 @@ public Charge Charge
internal ExpandableField<Charge> InternalCharge { get; set; }
#endregion

/// <summary>
/// Either <c>charge_automatically</c>, or <c>send_invoice</c>. When
/// charging automatically, Stripe will attempt to pay this invoice
/// using the default source attached to the customer. When sending an
/// invoice, Stripe will email this invoice to the customer with payment
/// instructions. Defaults to <c>charge_automatically</c>.
/// </summary>
[JsonProperty("collection_method")]
public string CollectionMethod { get; set; }

[JsonProperty("created")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime Created { get; set; }
Expand Down
7 changes: 7 additions & 0 deletions src/Stripe.net/Entities/Invoices/InvoiceLineItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,12 @@ public class InvoiceLineItem : StripeEntity<InvoiceLineItem>, IHasId, IHasMetada

[JsonProperty("type")]
public string Type { get; set; }

/// <summary>
/// Set to <c>true</c> if we grouped proration items into one,
/// <c>false</c> if not.
/// </summary>
[JsonProperty("unified_proration")]
public bool UnifiedProration { get; set; }
}
}
17 changes: 13 additions & 4 deletions src/Stripe.net/Entities/Subscriptions/Subscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ public class Subscription : StripeEntity<Subscription>, IHasId, IHasMetadata, IH
public decimal? ApplicationFeePercent { get; set; }

/// <summary>
/// One of <see cref="Billing" />. When charging automatically, Stripe will attempt to pay
/// this subscription at the end of the cycle using the default source attached to the
/// customer. When sending an invoice, Stripe will email your customer an invoice with
/// payment instructions.
/// This field has been renamed to <c>CollectionMethod</c> and will be removed
/// in a future API version.
/// </summary>
[Obsolete("Use CollectionMethod")]
[JsonProperty("billing")]
public Billing? Billing { get; set; }

Expand Down Expand Up @@ -50,6 +49,16 @@ public class Subscription : StripeEntity<Subscription>, IHasId, IHasMetadata, IH
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? CanceledAt { get; set; }

/// <summary>
/// Either <c>charge_automatically</c>, or <c>send_invoice</c>. When
/// charging automatically, Stripe will attempt to pay this subscription
/// at the end of the cycle using the default source attached to the
/// customer. When sending an invoice, Stripe will email your customer
/// an invoice with payment instructions.
/// </summary>
[JsonProperty("collection_method")]
public string CollectionMethod { get; set; }

[JsonProperty("created")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? Created { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ public class SubscriptionSchedule : StripeEntity<SubscriptionSchedule>, IHasId,
public string Object { get; set; }

/// <summary>
/// One of <see cref="Billing" />. When charging automatically, Stripe will attempt to pay
/// this subscription at the end of the cycle using the default source attached to the
/// customer. When sending an invoice, Stripe will email your customer an invoice with
/// payment instructions.
/// This field has been renamed to <c>CollectionMethod</c> and will be removed
/// in a future API version.
/// </summary>
[Obsolete("Use CollectionMethod")]
[JsonProperty("billing")]
public Billing? Billing { get; set; }

Expand All @@ -43,6 +42,16 @@ public class SubscriptionSchedule : StripeEntity<SubscriptionSchedule>, IHasId,
[JsonConverter(typeof(DateTimeConverter))]
public DateTime? CanceledAt { get; set; }

/// <summary>
/// Either <c>charge_automatically</c>, or <c>send_invoice</c>. When charging
/// automatically, Stripe will attempt to pay this subscription at the
/// end of the cycle using the default source attached to the customer.
/// When sending an invoice, Stripe will email your customer an invoice
/// with payment instructions.
/// </summary>
[JsonProperty("collection_method")]
public string CollectionMethod { get; set; }

/// <summary>
/// Time at which the subscription schedule was completed. Measured in seconds since the
/// Unix epoch.
Expand Down
6 changes: 6 additions & 0 deletions src/Stripe.net/Enums/Billing.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
namespace Stripe
{
using System;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

/// <summary>
/// The field this enum was used for has been renamed to
/// <c>CollectionMethod</c> and now accepts string.
/// </summary>
[Obsolete("Use CollectionMethod instead")]
[JsonConverter(typeof(StringEnumConverter))]
public enum Billing
{
Expand Down
17 changes: 13 additions & 4 deletions src/Stripe.net/Services/Invoices/InvoiceCreateOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,23 @@ public class InvoiceCreateOptions : BaseOptions
public bool? AutoAdvance { get; set; }

/// <summary>
/// One of <see cref="Billing" />. When charging automatically, Stripe will attempt to pay
/// this invoice using the default source attached to the customer. When sending an invoice,
/// Stripe will email this invoice to the customer with payment instructions. Defaults to
/// <c>charge_automatically</c>.
/// This field has been renamed to collection_method and will be removed
/// in a future API version.
/// </summary>
[Obsolete("Use CollectionMethod")]
[JsonProperty("billing")]
public Billing? Billing { get; set; }

/// <summary>
/// Either <c>charge_automatically</c>, or <c>send_invoice</c>. When
/// charging automatically, Stripe will attempt to pay this invoice
/// using the default source attached to the customer. When sending an
/// invoice, Stripe will email this invoice to the customer with payment
/// instructions. Defaults to <c>charge_automatically</c>.
/// </summary>
[JsonProperty("collection_method")]
public string CollectionMethod { get; set; }

/// <summary>
/// A list of up to 4 custom fields to be displayed on the invoice.
/// </summary>
Expand Down
10 changes: 9 additions & 1 deletion src/Stripe.net/Services/Invoices/InvoiceListOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@ namespace Stripe
public class InvoiceListOptions : ListOptions
{
/// <summary>
/// The billing mode of the invoice to retrieve. One of <see cref="Billing" />.
/// This field has been renamed to <c>CollectionMethod</c> and will be removed
/// in a future API version.
/// </summary>
[Obsolete("Use CollectionMethod")]
[JsonProperty("billing")]
public Billing? Billing { get; set; }

/// <summary>
/// Either <c>charge_automatically</c>, or <c>send_invoice</c>.
/// </summary>
[JsonProperty("collection_method")]
public string CollectionMethod { get; set; }

/// <summary>
/// A filter on the list based on the object <c>created</c> field. The value can be a
/// <see cref="DateTime"/> or a <see cref="DateRangeOptions"/>.
Expand Down
7 changes: 7 additions & 0 deletions src/Stripe.net/Services/Invoices/InvoiceUpdateOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ public class InvoiceUpdateOptions : BaseOptions
[JsonProperty("auto_advance")]
public bool? AutoAdvance { get; set; }

/// <summary>
/// Either <c>charge_automatically</c> or <c>send_invoice</c>. This
/// field can be updated only on <c>draft</c> invoices.
/// </summary>
[JsonProperty("collection_method")]
public string CollectionMethod { get; set; }

/// <summary>
/// A list of up to 4 custom fields to be displayed on the invoice.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ namespace Stripe
public abstract class SubscriptionScheduleSharedOptions : BaseOptions
{
/// <summary>
/// One of <see cref="Billing" />. When charging automatically, Stripe will attempt to pay
/// this subscription at the end of the cycle using the default source attached to the
/// customer. When sending an invoice, Stripe will email your customer an invoice with
/// payment instructions. Defaults to <c>charge_automatically</c>.
/// This field has been renamed to <c>CollectionMethod</c> and will be removed
/// in a future API version.
/// </summary>
[Obsolete("Use CollectionMethod")]
[JsonProperty("billing")]
public Billing? Billing { get; set; }

Expand All @@ -23,6 +22,17 @@ public abstract class SubscriptionScheduleSharedOptions : BaseOptions
[JsonProperty("billing_thresholds")]
public SubscriptionBillingThresholdsOptions BillingThresholds { get; set; }

/// <summary>
/// Either <c>charge_automatically</c>, or <c>send_invoice</c>. When
/// charging automatically, Stripe will attempt to pay the underlying
/// subscription at the end of each billing cycle using the default
/// source attached to the customer. When sending an invoice, Stripe
/// will email your customer an invoice with payment instructions.
/// Defaults to <c>charge_automatically</c> on creation.
/// </summary>
[JsonProperty("collection_method")]
public string CollectionMethod { get; set; }

/// <summary>
/// ID of the default payment method for the subscription schedule.
/// </summary>
Expand Down
12 changes: 11 additions & 1 deletion src/Stripe.net/Services/Subscriptions/SubscriptionListOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,21 @@ namespace Stripe
public class SubscriptionListOptions : ListOptionsWithCreated
{
/// <summary>
/// The billing mode of the subscriptions to retrieve. One of <see cref="Billing" />.
/// This field has been renamed to <c>CollectionMethod</c> and will be removed
/// in a future API version.
/// </summary>
[Obsolete("Use CollectionMethod")]
[JsonProperty("billing")]
public Billing? Billing { get; set; }

/// <summary>
/// A filter on the list based on the collection method for
/// subscriptions. Either <c>charge_automatically</c>, or
/// <c>send_invoice</c>.
/// </summary>
[JsonProperty("collection_method")]
public string CollectionMethod { get; set; }

/// <summary>
/// A filter on the list based on the object <c>current_period_end</c> field. The value can
/// be a <see cref="DateTime"/> or a <see cref="DateRangeOptions"/>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ public abstract class SubscriptionSharedOptions : BaseOptions
public decimal? ApplicationFeePercent { get; set; }

/// <summary>
/// One of <see cref="Billing" />. When charging automatically, Stripe will attempt to pay this subscription at the end of the cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions. Defaults to <c>charge_automatically</c>.
/// This field has been renamed to <c>CollectionMethod</c> and will be removed
/// in a future API version.
/// </summary>
[Obsolete("Use CollectionMethod")]
[JsonProperty("billing")]
public Billing? Billing { get; set; }

Expand All @@ -38,6 +40,17 @@ public abstract class SubscriptionSharedOptions : BaseOptions
[JsonProperty("cancel_at_period_end")]
public bool? CancelAtPeriodEnd { get; set; }

/// <summary>
/// Either <c>charge_automatically</c>, or <c>send_invoice</c>. When
/// charging automatically, Stripe will attempt to pay this invoice
/// using the default source attached to the customer. When sending an
/// invoice, Stripe will email invoices for this subscription to the
/// customer with payment instructions. Defaults to
/// <c>charge_automatically</c>.
/// </summary>
[JsonProperty("collection_method")]
public string CollectionMethod { get; set; }

/// <summary>
/// The code of the coupon to apply to this subscription. A coupon applied to a subscription will only affect invoices created for that particular subscription.
/// </summary>
Expand Down

0 comments on commit abc7011

Please sign in to comment.