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 transfer_data and application_fee_amount to Invoice and Subscriptions #1469

Merged
merged 2 commits into from
Feb 13, 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
10 changes: 10 additions & 0 deletions src/Stripe.net/Entities/Invoices/Invoice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

/// <summary>
/// The amount of the application application fee (if any) for the invoice. See the Connect documentation for details.
/// </summary>
[JsonProperty("application_fee_amount")]
public long? ApplicationFeeAmount { get; set; }

[JsonProperty("attempt_count")]
public long AttemptCount { get; set; }

Expand Down Expand Up @@ -237,6 +244,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; }

Expand Down
30 changes: 30 additions & 0 deletions src/Stripe.net/Entities/Invoices/InvoiceTransferData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
namespace Stripe
{
using Newtonsoft.Json;
using Stripe.Infrastructure;

public class InvoiceTransferData : StripeEntity
ob-stripe marked this conversation as resolved.
Show resolved Hide resolved
{
#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<Account>.Map(value, s => this.DestinationId = s, o => this.Destination = o);
}
}
#endregion
}
}
3 changes: 3 additions & 0 deletions src/Stripe.net/Entities/Subscriptions/Subscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
30 changes: 30 additions & 0 deletions src/Stripe.net/Entities/Subscriptions/SubscriptionTransferData.cs
Original file line number Diff line number Diff line change
@@ -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<Account>.Map(value, s => this.DestinationId = s, o => this.Destination = o);
}
}
#endregion
}
}
4 changes: 1 addition & 3 deletions src/Stripe.net/Services/Charges/ChargeCreateOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ public class ChargeCreateOptions : BaseOptions
[JsonProperty("currency")]
public string Currency { get; set; }

/// <summary>
/// This is deprecated in favor of ApplicationFeeAmount.
/// </summary>
[Obsolete("Use ApplicationFeeAmount")]
[JsonProperty("application_fee")]
public long? ApplicationFee { get; set; }

Expand Down
11 changes: 9 additions & 2 deletions src/Stripe.net/Services/Invoices/InvoiceCreateOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ namespace Stripe

public class InvoiceCreateOptions : BaseOptions
{
[Obsolete("Use ApplicationFeeAmount")]
[JsonProperty("application_fee")]
public long? ApplicationFee { get; set; }

/// <summary>
/// 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 <see href="https://stripe.com/docs/connect/subscriptions#working-with-invoices">documentation</see>.
/// </summary>
[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; }
Expand Down Expand Up @@ -91,5 +95,8 @@ public class InvoiceCreateOptions : BaseOptions
/// </summary>
[JsonProperty("tax_percent")]
public decimal? TaxPercent { get; set; }

[JsonProperty("transfer_data")]
public InvoiceTransferDataOptions TransferData { get; set; }
}
}
10 changes: 10 additions & 0 deletions src/Stripe.net/Services/Invoices/InvoiceTransferDataOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Stripe
{
using Newtonsoft.Json;

public class InvoiceTransferDataOptions : INestedOptions
{
[JsonProperty("destination")]
public string Destination { get; set; }
}
}
13 changes: 13 additions & 0 deletions src/Stripe.net/Services/Invoices/InvoiceUpdateOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@ namespace Stripe

public class InvoiceUpdateOptions : BaseOptions
{
[Obsolete("Use ApplicationFeeAmount")]
[JsonProperty("application_fee")]
public long? ApplicationFee { get; set; }

/// <summary>
/// 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 <see href="https://stripe.com/docs/connect/subscriptions#working-with-invoices">documentation</see>.
/// </summary>
[JsonProperty("application_fee_amount")]
public long? ApplicationFeeAmount { get; set; }

[JsonProperty("auto_advance")]
public bool? AutoAdvance { get; set; }

Expand Down Expand Up @@ -51,5 +61,8 @@ public class InvoiceUpdateOptions : BaseOptions

[JsonProperty("tax_percent")]
public decimal? TaxPercent { get; set; }

[JsonProperty("transfer_data")]
public InvoiceTransferDataOptions TransferData { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Stripe
{
using Newtonsoft.Json;

public class SubscriptionTransferDataOptions : INestedOptions
{
[JsonProperty("destination")]
public string Destination { get; set; }
}
}