From abc701158cbd13b9cdd515afac036b6a913bd824 Mon Sep 17 00:00:00 2001 From: CJ Avilla Date: Tue, 2 Jul 2019 11:39:04 -0700 Subject: [PATCH] Add CollectionMethod for Invoices and Subscriptions --- .../Entities/InvoiceItems/InvoiceItem.cs | 7 +++++++ src/Stripe.net/Entities/Invoices/Invoice.cs | 17 +++++++++++++---- .../Entities/Invoices/InvoiceLineItem.cs | 7 +++++++ .../Entities/Subscriptions/Subscription.cs | 17 +++++++++++++---- .../SubscriptionSchedule.cs | 17 +++++++++++++---- src/Stripe.net/Enums/Billing.cs | 6 ++++++ .../Services/Invoices/InvoiceCreateOptions.cs | 17 +++++++++++++---- .../Services/Invoices/InvoiceListOptions.cs | 10 +++++++++- .../Services/Invoices/InvoiceUpdateOptions.cs | 7 +++++++ .../SubscriptionScheduleSharedOptions.cs | 18 ++++++++++++++---- .../Subscriptions/SubscriptionListOptions.cs | 12 +++++++++++- .../Subscriptions/SubscriptionSharedOptions.cs | 15 ++++++++++++++- 12 files changed, 127 insertions(+), 23 deletions(-) diff --git a/src/Stripe.net/Entities/InvoiceItems/InvoiceItem.cs b/src/Stripe.net/Entities/InvoiceItems/InvoiceItem.cs index d987e7cb1a..36f3207146 100644 --- a/src/Stripe.net/Entities/InvoiceItems/InvoiceItem.cs +++ b/src/Stripe.net/Entities/InvoiceItems/InvoiceItem.cs @@ -122,6 +122,13 @@ public Subscription Subscription [JsonProperty("tax_rates")] public List TaxRates { get; set; } + /// + /// Set to true if we grouped proration items into one, + /// false if not. + /// + [JsonProperty("unified_proration")] + public bool UnifiedProration { get; set; } + [JsonProperty("unit_amount")] public long? UnitAmount { get; set; } } diff --git a/src/Stripe.net/Entities/Invoices/Invoice.cs b/src/Stripe.net/Entities/Invoices/Invoice.cs index ce98371142..12f58b0a55 100644 --- a/src/Stripe.net/Entities/Invoices/Invoice.cs +++ b/src/Stripe.net/Entities/Invoices/Invoice.cs @@ -52,11 +52,10 @@ public class Invoice : StripeEntity, IHasId, IHasMetadata, IHasObject public bool AutoAdvance { get; set; } /// - /// One of . 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 CollectionMethod and will be removed + /// in a future API version. /// + [Obsolete("Use CollectionMethod")] [JsonProperty("billing")] public Billing? Billing { get; set; } @@ -83,6 +82,16 @@ public Charge Charge internal ExpandableField InternalCharge { get; set; } #endregion + /// + /// Either charge_automatically, or send_invoice. 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 charge_automatically. + /// + [JsonProperty("collection_method")] + public string CollectionMethod { get; set; } + [JsonProperty("created")] [JsonConverter(typeof(DateTimeConverter))] public DateTime Created { get; set; } diff --git a/src/Stripe.net/Entities/Invoices/InvoiceLineItem.cs b/src/Stripe.net/Entities/Invoices/InvoiceLineItem.cs index d746bfcb90..80b5059f74 100644 --- a/src/Stripe.net/Entities/Invoices/InvoiceLineItem.cs +++ b/src/Stripe.net/Entities/Invoices/InvoiceLineItem.cs @@ -70,5 +70,12 @@ public class InvoiceLineItem : StripeEntity, IHasId, IHasMetada [JsonProperty("type")] public string Type { get; set; } + + /// + /// Set to true if we grouped proration items into one, + /// false if not. + /// + [JsonProperty("unified_proration")] + public bool UnifiedProration { get; set; } } } diff --git a/src/Stripe.net/Entities/Subscriptions/Subscription.cs b/src/Stripe.net/Entities/Subscriptions/Subscription.cs index b81b7c0007..41852ba91a 100644 --- a/src/Stripe.net/Entities/Subscriptions/Subscription.cs +++ b/src/Stripe.net/Entities/Subscriptions/Subscription.cs @@ -17,11 +17,10 @@ public class Subscription : StripeEntity, IHasId, IHasMetadata, IH public decimal? ApplicationFeePercent { get; set; } /// - /// One of . 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 CollectionMethod and will be removed + /// in a future API version. /// + [Obsolete("Use CollectionMethod")] [JsonProperty("billing")] public Billing? Billing { get; set; } @@ -50,6 +49,16 @@ public class Subscription : StripeEntity, IHasId, IHasMetadata, IH [JsonConverter(typeof(DateTimeConverter))] public DateTime? CanceledAt { get; set; } + /// + /// Either charge_automatically, or send_invoice. 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. + /// + [JsonProperty("collection_method")] + public string CollectionMethod { get; set; } + [JsonProperty("created")] [JsonConverter(typeof(DateTimeConverter))] public DateTime? Created { get; set; } diff --git a/src/Stripe.net/Entities/SubscriptionsSchedules/SubscriptionSchedule.cs b/src/Stripe.net/Entities/SubscriptionsSchedules/SubscriptionSchedule.cs index 341200c2d4..5a24489496 100644 --- a/src/Stripe.net/Entities/SubscriptionsSchedules/SubscriptionSchedule.cs +++ b/src/Stripe.net/Entities/SubscriptionsSchedules/SubscriptionSchedule.cs @@ -20,11 +20,10 @@ public class SubscriptionSchedule : StripeEntity, IHasId, public string Object { get; set; } /// - /// One of . 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 CollectionMethod and will be removed + /// in a future API version. /// + [Obsolete("Use CollectionMethod")] [JsonProperty("billing")] public Billing? Billing { get; set; } @@ -43,6 +42,16 @@ public class SubscriptionSchedule : StripeEntity, IHasId, [JsonConverter(typeof(DateTimeConverter))] public DateTime? CanceledAt { get; set; } + /// + /// Either charge_automatically, or send_invoice. 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. + /// + [JsonProperty("collection_method")] + public string CollectionMethod { get; set; } + /// /// Time at which the subscription schedule was completed. Measured in seconds since the /// Unix epoch. diff --git a/src/Stripe.net/Enums/Billing.cs b/src/Stripe.net/Enums/Billing.cs index d3f7f6c556..c3f3cdc14e 100644 --- a/src/Stripe.net/Enums/Billing.cs +++ b/src/Stripe.net/Enums/Billing.cs @@ -1,9 +1,15 @@ namespace Stripe { + using System; using System.Runtime.Serialization; using Newtonsoft.Json; using Newtonsoft.Json.Converters; + /// + /// The field this enum was used for has been renamed to + /// CollectionMethod and now accepts string. + /// + [Obsolete("Use CollectionMethod instead")] [JsonConverter(typeof(StringEnumConverter))] public enum Billing { diff --git a/src/Stripe.net/Services/Invoices/InvoiceCreateOptions.cs b/src/Stripe.net/Services/Invoices/InvoiceCreateOptions.cs index eae859b1cd..d32a2ae7be 100644 --- a/src/Stripe.net/Services/Invoices/InvoiceCreateOptions.cs +++ b/src/Stripe.net/Services/Invoices/InvoiceCreateOptions.cs @@ -20,14 +20,23 @@ public class InvoiceCreateOptions : BaseOptions public bool? AutoAdvance { get; set; } /// - /// One of . 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 - /// charge_automatically. + /// This field has been renamed to collection_method and will be removed + /// in a future API version. /// + [Obsolete("Use CollectionMethod")] [JsonProperty("billing")] public Billing? Billing { get; set; } + /// + /// Either charge_automatically, or send_invoice. 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 charge_automatically. + /// + [JsonProperty("collection_method")] + public string CollectionMethod { get; set; } + /// /// A list of up to 4 custom fields to be displayed on the invoice. /// diff --git a/src/Stripe.net/Services/Invoices/InvoiceListOptions.cs b/src/Stripe.net/Services/Invoices/InvoiceListOptions.cs index e5240eea1e..177795efa4 100644 --- a/src/Stripe.net/Services/Invoices/InvoiceListOptions.cs +++ b/src/Stripe.net/Services/Invoices/InvoiceListOptions.cs @@ -7,11 +7,19 @@ namespace Stripe public class InvoiceListOptions : ListOptions { /// - /// The billing mode of the invoice to retrieve. One of . + /// This field has been renamed to CollectionMethod and will be removed + /// in a future API version. /// + [Obsolete("Use CollectionMethod")] [JsonProperty("billing")] public Billing? Billing { get; set; } + /// + /// Either charge_automatically, or send_invoice. + /// + [JsonProperty("collection_method")] + public string CollectionMethod { get; set; } + /// /// A filter on the list based on the object created field. The value can be a /// or a . diff --git a/src/Stripe.net/Services/Invoices/InvoiceUpdateOptions.cs b/src/Stripe.net/Services/Invoices/InvoiceUpdateOptions.cs index 48badaef57..da932d5530 100644 --- a/src/Stripe.net/Services/Invoices/InvoiceUpdateOptions.cs +++ b/src/Stripe.net/Services/Invoices/InvoiceUpdateOptions.cs @@ -19,6 +19,13 @@ public class InvoiceUpdateOptions : BaseOptions [JsonProperty("auto_advance")] public bool? AutoAdvance { get; set; } + /// + /// Either charge_automatically or send_invoice. This + /// field can be updated only on draft invoices. + /// + [JsonProperty("collection_method")] + public string CollectionMethod { get; set; } + /// /// A list of up to 4 custom fields to be displayed on the invoice. /// diff --git a/src/Stripe.net/Services/SubscriptionSchedules/SubscriptionScheduleSharedOptions.cs b/src/Stripe.net/Services/SubscriptionSchedules/SubscriptionScheduleSharedOptions.cs index b8735469ef..2a4b6b788b 100644 --- a/src/Stripe.net/Services/SubscriptionSchedules/SubscriptionScheduleSharedOptions.cs +++ b/src/Stripe.net/Services/SubscriptionSchedules/SubscriptionScheduleSharedOptions.cs @@ -8,11 +8,10 @@ namespace Stripe public abstract class SubscriptionScheduleSharedOptions : BaseOptions { /// - /// One of . 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 charge_automatically. + /// This field has been renamed to CollectionMethod and will be removed + /// in a future API version. /// + [Obsolete("Use CollectionMethod")] [JsonProperty("billing")] public Billing? Billing { get; set; } @@ -23,6 +22,17 @@ public abstract class SubscriptionScheduleSharedOptions : BaseOptions [JsonProperty("billing_thresholds")] public SubscriptionBillingThresholdsOptions BillingThresholds { get; set; } + /// + /// Either charge_automatically, or send_invoice. 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 charge_automatically on creation. + /// + [JsonProperty("collection_method")] + public string CollectionMethod { get; set; } + /// /// ID of the default payment method for the subscription schedule. /// diff --git a/src/Stripe.net/Services/Subscriptions/SubscriptionListOptions.cs b/src/Stripe.net/Services/Subscriptions/SubscriptionListOptions.cs index 69fcbb4179..5b68631845 100644 --- a/src/Stripe.net/Services/Subscriptions/SubscriptionListOptions.cs +++ b/src/Stripe.net/Services/Subscriptions/SubscriptionListOptions.cs @@ -7,11 +7,21 @@ namespace Stripe public class SubscriptionListOptions : ListOptionsWithCreated { /// - /// The billing mode of the subscriptions to retrieve. One of . + /// This field has been renamed to CollectionMethod and will be removed + /// in a future API version. /// + [Obsolete("Use CollectionMethod")] [JsonProperty("billing")] public Billing? Billing { get; set; } + /// + /// A filter on the list based on the collection method for + /// subscriptions. Either charge_automatically, or + /// send_invoice. + /// + [JsonProperty("collection_method")] + public string CollectionMethod { get; set; } + /// /// A filter on the list based on the object current_period_end field. The value can /// be a or a . diff --git a/src/Stripe.net/Services/Subscriptions/SubscriptionSharedOptions.cs b/src/Stripe.net/Services/Subscriptions/SubscriptionSharedOptions.cs index cf720513a1..14a3b0e321 100644 --- a/src/Stripe.net/Services/Subscriptions/SubscriptionSharedOptions.cs +++ b/src/Stripe.net/Services/Subscriptions/SubscriptionSharedOptions.cs @@ -14,8 +14,10 @@ public abstract class SubscriptionSharedOptions : BaseOptions public decimal? ApplicationFeePercent { get; set; } /// - /// One of . 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 charge_automatically. + /// This field has been renamed to CollectionMethod and will be removed + /// in a future API version. /// + [Obsolete("Use CollectionMethod")] [JsonProperty("billing")] public Billing? Billing { get; set; } @@ -38,6 +40,17 @@ public abstract class SubscriptionSharedOptions : BaseOptions [JsonProperty("cancel_at_period_end")] public bool? CancelAtPeriodEnd { get; set; } + /// + /// Either charge_automatically, or send_invoice. 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 + /// charge_automatically. + /// + [JsonProperty("collection_method")] + public string CollectionMethod { get; set; } + /// /// 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. ///