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 spending_limits on Issuing Card and Cardholder #1576

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 3 additions & 0 deletions src/Stripe.net/Entities/Issuing/Cardholders/Cardholder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public class Cardholder : StripeEntity, IHasId, IHasMetadata, IHasObject
[JsonProperty("object")]
public string Object { get; set; }

[JsonProperty("authorization_controls")]
public AuthorizationControls AuthorizationControls { get; set; }

[JsonProperty("billing")]
public Billing Billing { get; set; }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,38 @@
namespace Stripe.Issuing
{
using System;
using System.Collections.Generic;
using Newtonsoft.Json;

public class AuthorizationControls : StripeEntity
{
/// <summary>
/// Categories of authorizations permitted on this card.
/// </summary>
[JsonProperty("allowed_categories")]
public List<string> AllowedCategories { get; set; }

/// <summary>
/// Categories of authorizations to always decline on this card.
/// </summary>
[JsonProperty("blocked_categories")]
public List<string> BlockedCategories { get; set; }

/// <summary>
/// Limit the spending with rules based on time intervals and categories.
/// </summary>
[JsonProperty("spending_limits")]
public List<SpendingLimit> SpendingLimits { get; set; }

[Obsolete("This is now unsupported")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we improve this message? This isn't super helpful 😂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm I was not sure what to put. Like there's no replacement or anything. It's just removed as a property.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ob-stripe What do you think of this one?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to change it? The message hasn't changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am asking you what I should put. This option is just entirely removed, it's not replaced by anything. So I don't know what to put beyond "please stop using it". Do you have any idea what string would be enough for you?

[JsonProperty("currency")]
public string Currency { get; set; }

[Obsolete("Use SpendingLimits")]
[JsonProperty("max_amount")]
public long? MaxAmount { get; set; }

[Obsolete("Use SpendingLimits")]
[JsonProperty("max_approvals")]
public long? MaxApprovals { get; set; }
}
Expand Down
28 changes: 28 additions & 0 deletions src/Stripe.net/Entities/Issuing/Cards/SpendingLimit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace Stripe.Issuing
{
using System.Collections.Generic;
using Newtonsoft.Json;

public class SpendingLimit : StripeEntity
{
/// <summary>
/// Maximum amount allowed to spend per time interval.
/// </summary>
[JsonProperty("amount")]
public long? Amount { get; set; }

/// <summary>
/// Categories on which to apply the spending limit. Leave this empty to limit all charges.
/// </summary>
[JsonProperty("categories")]
public List<string> Categories { get; set; }

/// <summary>
/// The time interval with which to apply this spending limit towards. Allowed values are
/// <c>per_authorization</c>, <c>daily</c>, <c>weekly</c>, <c>monthly</c>, <c>yearly</c>,
/// or <c>all_time</c>.
/// </summary>
[JsonProperty("interval")]
public string Interval { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ namespace Stripe.Issuing

public class CardholderCreateOptions : CardholderSharedOptions
{
/// <summary>
/// The type of cardholder. Possible values are <c>individual</c> or <c>business_entity</c>.
/// </summary>
[JsonProperty("type")]
public string Type { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,35 @@ namespace Stripe.Issuing

public class CardholderListOptions : ListOptionsWithCreated
{
/// <summary>
/// Only return cardholders that have the given email address.
/// </summary>
[JsonProperty("email")]
public string Email { get; set; }

/// <summary>
/// Only return the default cardholder.
/// </summary>
[JsonProperty("is_default")]
public bool? IsDefault { get; set; }

/// <summary>
/// Only return cardholders that have the given phone number.
/// </summary>
[JsonProperty("phone_number")]
public string PhoneNumber { get; set; }

/// <summary>
/// Only return cardholders that have the given status. One of <c>active</c>,
/// <c>inactive</c>, or <c>blocked</c>.
/// </summary>
[JsonProperty("status")]
public string Status { get; set; }

/// <summary>
/// Only return cardholders that have the given type. One of <c>individual</c> or
/// <c>business_entity</c>.
/// </summary>
[JsonProperty("type")]
public string Type { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,53 @@ namespace Stripe.Issuing

public class CardholderSharedOptions : BaseOptions
{
/// <summary>
/// Spending rules that give you control over how your cardholders can make charges.
/// </summary>
[JsonProperty("authorization_controls")]
public AuthorizationControlsOptions AuthorizationControls { get; set; }

/// <summary>
/// The cardholder’s billing address.
/// </summary>
[JsonProperty("billing")]
public BillingOptions Billing { get; set; }

/// <summary>
/// The cardholder’s email address.
/// </summary>
[JsonProperty("email")]
public string Email { get; set; }

/// <summary>
/// Specifies whether to set this as the default cardholder.
/// </summary>
[JsonProperty("is_default")]
public bool? IsDefault { get; set; }

/// <summary>
/// A set of key/value pairs that you can attach to a charge object. It can be useful for
/// storing additional information about the charge in a structured format.
/// </summary>
[JsonProperty("metadata")]
public Dictionary<string, string> Metadata { get; set; }

/// <summary>
/// The cardholder’s name. This will be printed on cards issued to them.
/// </summary>
[JsonProperty("name")]
public string Name { get; set; }

/// <summary>
/// Maximum amount allowed to spend per time interval.
/// </summary>
[JsonProperty("phone_number")]
public string PhoneNumber { get; set; }

/// <summary>
/// Specifies whether to permit authorizations on this cardholder’s cards. Possible values
/// are <c>active</c> or <c>inactive</c>.
/// </summary>
[JsonProperty("status")]
public string Status { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
namespace Stripe.Issuing
{
using System;
using System.Collections.Generic;
using Newtonsoft.Json;

public class AuthorizationControlsOptions : INestedOptions
{
/// <summary>
/// Categories of authorizations permitted on this card.
/// </summary>
[JsonProperty("allowed_categories")]
public List<string> AllowedCategories { get; set; }

/// <summary>
/// Categories of authorizations to always decline on this card.
/// </summary>
[JsonProperty("blocked_categories")]
public List<string> BlockedCategories { get; set; }

/// <summary>
/// Limit the spending with rules based on time intervals and categories.
/// </summary>
[JsonProperty("spending_limits")]
public List<SpendingLimitOptions> SpendingLimits { get; set; }

[Obsolete("Use SpendingLimits")]
[JsonProperty("max_amount")]
public long? MaxAmount { get; set; }

[Obsolete("Use SpendingLimits")]
[JsonProperty("max_approvals")]
public long? MaxApprovals { get; set; }
}
Expand Down
28 changes: 28 additions & 0 deletions src/Stripe.net/Services/Issuing/Cards/SpendingLimitOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace Stripe.Issuing
{
using System.Collections.Generic;
using Newtonsoft.Json;

public class SpendingLimitOptions : INestedOptions
{
/// <summary>
/// Maximum amount allowed to spend per time interval.
/// </summary>
[JsonProperty("amount")]
public long? Amount { get; set; }

/// <summary>
/// categories on which to apply the spending limit. Leave this empty to limit all charges.
/// </summary>
[JsonProperty("categories")]
public List<string> Categories { get; set; }

/// <summary>
/// The time interval with which to apply this spending limit towards. Allowed values are
/// <c>per_authorization</c>, <c>daily</c>, <c>weekly</c>, <c>monthly</c>, <c>yearly</c>,
/// or <c>all_time</c>.
/// </summary>
[JsonProperty("interval")]
public string Interval { get; set; }
}
}
13 changes: 12 additions & 1 deletion src/StripeTests/Services/Issuing/Cards/IssuingCardServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,18 @@ public IssuingCardServiceTest(MockHttpClientFixture mockHttpClientFixture)
{
AuthorizationControls = new AuthorizationControlsOptions
{
MaxAmount = 123,
SpendingLimits = new List<SpendingLimitOptions>
{
new SpendingLimitOptions
{
Amount = 1000,
Categories = new List<string>
{
"financial_institutions",
},
Interval = "all_time",
},
},
},
Currency = "usd",
Type = "virtual",
Expand Down