From 2ba21954924d0a64bde6066062ddd639a8b3ee6e Mon Sep 17 00:00:00 2001 From: Remi Jannel Date: Thu, 10 Jan 2019 18:40:41 -0800 Subject: [PATCH 1/2] Add support for `transfer_data` on Subscription and Invoice --- src/Stripe.net/Entities/Invoices/Invoice.cs | 3 ++ .../Entities/Invoices/InvoiceTransferData.cs | 30 +++++++++++++++++++ .../Entities/Subscriptions/Subscription.cs | 3 ++ .../Subscriptions/SubscriptionTransferData.cs | 30 +++++++++++++++++++ .../Services/Invoices/InvoiceCreateOptions.cs | 3 ++ .../Invoices/InvoiceTransferDataOptions.cs | 10 +++++++ .../Services/Invoices/InvoiceUpdateOptions.cs | 3 ++ .../SubscriptionSharedOptions.cs | 3 ++ .../SubscriptionTransferDataOptions.cs | 10 +++++++ 9 files changed, 95 insertions(+) create mode 100644 src/Stripe.net/Entities/Invoices/InvoiceTransferData.cs create mode 100644 src/Stripe.net/Entities/Subscriptions/SubscriptionTransferData.cs create mode 100644 src/Stripe.net/Services/Invoices/InvoiceTransferDataOptions.cs create mode 100644 src/Stripe.net/Services/Subscriptions/SubscriptionTransferDataOptions.cs diff --git a/src/Stripe.net/Entities/Invoices/Invoice.cs b/src/Stripe.net/Entities/Invoices/Invoice.cs index dd48f57318..5f46c623b0 100644 --- a/src/Stripe.net/Entities/Invoices/Invoice.cs +++ b/src/Stripe.net/Entities/Invoices/Invoice.cs @@ -237,6 +237,9 @@ internal object InternalSubscription [JsonProperty("threshold_reason")] public InvoiceThresholdReason ThresholdReason { get; set; } + [JsonProperty("transfer_data")] + public InvoiceTransferData TransferData { get; set; } + [JsonProperty("total")] public long Total { get; set; } diff --git a/src/Stripe.net/Entities/Invoices/InvoiceTransferData.cs b/src/Stripe.net/Entities/Invoices/InvoiceTransferData.cs new file mode 100644 index 0000000000..112624d698 --- /dev/null +++ b/src/Stripe.net/Entities/Invoices/InvoiceTransferData.cs @@ -0,0 +1,30 @@ +namespace Stripe +{ + using Newtonsoft.Json; + using Stripe.Infrastructure; + + public class InvoiceTransferData : StripeEntity + { + #region Expandable Destination (Account) + [JsonIgnore] + public string DestinationId { get; set; } + + [JsonIgnore] + public Account Destination { get; set; } + + [JsonProperty("destination")] + internal object InternalDestination + { + get + { + return this.Destination ?? (object)this.DestinationId; + } + + set + { + StringOrObject.Map(value, s => this.DestinationId = s, o => this.Destination = o); + } + } + #endregion + } +} diff --git a/src/Stripe.net/Entities/Subscriptions/Subscription.cs b/src/Stripe.net/Entities/Subscriptions/Subscription.cs index d9b02cd26c..133244aa3a 100644 --- a/src/Stripe.net/Entities/Subscriptions/Subscription.cs +++ b/src/Stripe.net/Entities/Subscriptions/Subscription.cs @@ -137,6 +137,9 @@ internal object InternalDefaultSource [JsonProperty("tax_percent")] public decimal? TaxPercent { get; set; } + [JsonProperty("transfer_data")] + public SubscriptionTransferData TransferData { get; set; } + [JsonProperty("trial_end")] [JsonConverter(typeof(DateTimeConverter))] public DateTime? TrialEnd { get; set; } diff --git a/src/Stripe.net/Entities/Subscriptions/SubscriptionTransferData.cs b/src/Stripe.net/Entities/Subscriptions/SubscriptionTransferData.cs new file mode 100644 index 0000000000..de389f3849 --- /dev/null +++ b/src/Stripe.net/Entities/Subscriptions/SubscriptionTransferData.cs @@ -0,0 +1,30 @@ +namespace Stripe +{ + using Newtonsoft.Json; + using Stripe.Infrastructure; + + public class SubscriptionTransferData : StripeEntity + { + #region Expandable Destination (Account) + [JsonIgnore] + public string DestinationId { get; set; } + + [JsonIgnore] + public Account Destination { get; set; } + + [JsonProperty("destination")] + internal object InternalDestination + { + get + { + return this.Destination ?? (object)this.DestinationId; + } + + set + { + StringOrObject.Map(value, s => this.DestinationId = s, o => this.Destination = o); + } + } + #endregion + } +} diff --git a/src/Stripe.net/Services/Invoices/InvoiceCreateOptions.cs b/src/Stripe.net/Services/Invoices/InvoiceCreateOptions.cs index 393f0b0ba7..c7f090c103 100644 --- a/src/Stripe.net/Services/Invoices/InvoiceCreateOptions.cs +++ b/src/Stripe.net/Services/Invoices/InvoiceCreateOptions.cs @@ -91,5 +91,8 @@ public class InvoiceCreateOptions : BaseOptions /// [JsonProperty("tax_percent")] public decimal? TaxPercent { get; set; } + + [JsonProperty("transfer_data")] + public InvoiceTransferDataOptions TransferData { get; set; } } } diff --git a/src/Stripe.net/Services/Invoices/InvoiceTransferDataOptions.cs b/src/Stripe.net/Services/Invoices/InvoiceTransferDataOptions.cs new file mode 100644 index 0000000000..821f90b01e --- /dev/null +++ b/src/Stripe.net/Services/Invoices/InvoiceTransferDataOptions.cs @@ -0,0 +1,10 @@ +namespace Stripe +{ + using Newtonsoft.Json; + + public class InvoiceTransferDataOptions : INestedOptions + { + [JsonProperty("destination")] + public string Destination { get; set; } + } +} diff --git a/src/Stripe.net/Services/Invoices/InvoiceUpdateOptions.cs b/src/Stripe.net/Services/Invoices/InvoiceUpdateOptions.cs index 4446d4f5ae..717d0a8c44 100644 --- a/src/Stripe.net/Services/Invoices/InvoiceUpdateOptions.cs +++ b/src/Stripe.net/Services/Invoices/InvoiceUpdateOptions.cs @@ -51,5 +51,8 @@ public class InvoiceUpdateOptions : BaseOptions [JsonProperty("tax_percent")] public decimal? TaxPercent { get; set; } + + [JsonProperty("transfer_data")] + public InvoiceTransferDataOptions TransferData { get; set; } } } diff --git a/src/Stripe.net/Services/Subscriptions/SubscriptionSharedOptions.cs b/src/Stripe.net/Services/Subscriptions/SubscriptionSharedOptions.cs index e7a3f92982..4665512dc6 100644 --- a/src/Stripe.net/Services/Subscriptions/SubscriptionSharedOptions.cs +++ b/src/Stripe.net/Services/Subscriptions/SubscriptionSharedOptions.cs @@ -90,5 +90,8 @@ public abstract class SubscriptionSharedOptions : BaseOptions [Obsolete("Use Items")] [JsonProperty("quantity")] public long? Quantity { get; set; } + + [JsonProperty("transfer_data")] + public SubscriptionTransferDataOptions TransferData { get; set; } } } diff --git a/src/Stripe.net/Services/Subscriptions/SubscriptionTransferDataOptions.cs b/src/Stripe.net/Services/Subscriptions/SubscriptionTransferDataOptions.cs new file mode 100644 index 0000000000..bc9fce3251 --- /dev/null +++ b/src/Stripe.net/Services/Subscriptions/SubscriptionTransferDataOptions.cs @@ -0,0 +1,10 @@ +namespace Stripe +{ + using Newtonsoft.Json; + + public class SubscriptionTransferDataOptions : INestedOptions + { + [JsonProperty("destination")] + public string Destination { get; set; } + } +} From 83d54c7e229ffb5a9d73738750cf38e942f88e21 Mon Sep 17 00:00:00 2001 From: Remi Jannel Date: Thu, 10 Jan 2019 18:45:04 -0800 Subject: [PATCH 2/2] Add support for `application_fee_amount` on Invoice --- src/Stripe.net/Entities/Invoices/Invoice.cs | 7 +++++++ src/Stripe.net/Services/Charges/ChargeCreateOptions.cs | 4 +--- .../Services/Invoices/InvoiceCreateOptions.cs | 8 ++++++-- .../Services/Invoices/InvoiceUpdateOptions.cs | 10 ++++++++++ 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/Stripe.net/Entities/Invoices/Invoice.cs b/src/Stripe.net/Entities/Invoices/Invoice.cs index 5f46c623b0..383619fbfa 100644 --- a/src/Stripe.net/Entities/Invoices/Invoice.cs +++ b/src/Stripe.net/Entities/Invoices/Invoice.cs @@ -22,9 +22,16 @@ public class Invoice : StripeEntity, IHasId, IHasMetadata, IHasObject [JsonProperty("amount_remaining")] public long AmountRemaining { get; set; } + [Obsolete("Use ApplicationFeeAmount")] [JsonProperty("application_fee")] public long? ApplicationFee { get; set; } + /// + /// The amount of the application application fee (if any) for the invoice. See the Connect documentation for details. + /// + [JsonProperty("application_fee_amount")] + public long? ApplicationFeeAmount { get; set; } + [JsonProperty("attempt_count")] public long AttemptCount { get; set; } diff --git a/src/Stripe.net/Services/Charges/ChargeCreateOptions.cs b/src/Stripe.net/Services/Charges/ChargeCreateOptions.cs index 45ba602bf6..ffbdd6dc7f 100644 --- a/src/Stripe.net/Services/Charges/ChargeCreateOptions.cs +++ b/src/Stripe.net/Services/Charges/ChargeCreateOptions.cs @@ -18,9 +18,7 @@ public class ChargeCreateOptions : BaseOptions [JsonProperty("currency")] public string Currency { get; set; } - /// - /// This is deprecated in favor of ApplicationFeeAmount. - /// + [Obsolete("Use ApplicationFeeAmount")] [JsonProperty("application_fee")] public long? ApplicationFee { get; set; } diff --git a/src/Stripe.net/Services/Invoices/InvoiceCreateOptions.cs b/src/Stripe.net/Services/Invoices/InvoiceCreateOptions.cs index c7f090c103..eebd0a003b 100644 --- a/src/Stripe.net/Services/Invoices/InvoiceCreateOptions.cs +++ b/src/Stripe.net/Services/Invoices/InvoiceCreateOptions.cs @@ -7,14 +7,18 @@ namespace Stripe public class InvoiceCreateOptions : BaseOptions { + [Obsolete("Use ApplicationFeeAmount")] + [JsonProperty("application_fee")] + public long? ApplicationFee { get; set; } + /// /// A fee in cents that will be applied to the invoice and transferred to the application /// owner’s Stripe account. The request must be made with an OAuth key or the Stripe-Account /// header in order to take an application fee. For more information, see the application /// fees documentation. /// - [JsonProperty("application_fee")] - public long? ApplicationFee { get; set; } + [JsonProperty("application_fee_amount")] + public long? ApplicationFeeAmount { get; set; } [JsonProperty("auto_advance")] public bool? AutoAdvance { get; set; } diff --git a/src/Stripe.net/Services/Invoices/InvoiceUpdateOptions.cs b/src/Stripe.net/Services/Invoices/InvoiceUpdateOptions.cs index 717d0a8c44..9e0625cccb 100644 --- a/src/Stripe.net/Services/Invoices/InvoiceUpdateOptions.cs +++ b/src/Stripe.net/Services/Invoices/InvoiceUpdateOptions.cs @@ -7,9 +7,19 @@ namespace Stripe public class InvoiceUpdateOptions : BaseOptions { + [Obsolete("Use ApplicationFeeAmount")] [JsonProperty("application_fee")] public long? ApplicationFee { get; set; } + /// + /// A fee in cents that will be applied to the invoice and transferred to the application + /// owner’s Stripe account. The request must be made with an OAuth key or the Stripe-Account + /// header in order to take an application fee. For more information, see the application + /// fees documentation. + /// + [JsonProperty("application_fee_amount")] + public long? ApplicationFeeAmount { get; set; } + [JsonProperty("auto_advance")] public bool? AutoAdvance { get; set; }