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 AuthorizationControls on Issuing Cardholder #1877

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

/// <summary>
/// Spending rules that give you control over how your cardholder can make charges.
/// </summary>
[JsonProperty("authorization_controls")]
public CardholderAuthorizationControls AuthorizationControls { get; set; }

/// <summary>
/// The cardholder’s billing address.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
namespace Stripe
{
using System.Collections.Generic;
using Newtonsoft.Json;

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

/// <summary>
/// Categories of authorizations to always decline for this cardholder.
/// </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<CardholderAuthorizationControlsSpendingLimit> SpendingLimits { get; set; }

/// <summary>
/// Currency for the amounts within <see cref="SpendingLimits"/>.
/// </summary>
[JsonProperty("spending_limits_currency")]
public string SpendingLimitsCurrency { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace Stripe
{
using System.Collections.Generic;
using Newtonsoft.Json;

public class CardholderAuthorizationControlsSpendingLimit : StripeEntity<CardholderAuthorizationControlsSpendingLimit>
{
/// <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
@@ -0,0 +1,32 @@
namespace Stripe.Issuing
{
using System.Collections.Generic;
using Newtonsoft.Json;

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

/// <summary>
/// Categories of authorizations to always decline for this cardholder.
/// </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<CardholderAuthorizationControlsSpendingLimitOptions> SpendingLimits { get; set; }

/// <summary>
/// Currency for the amounts within <see cref="SpendingLimits"/>.
/// </summary>
[JsonProperty("spending_limits_currency")]
public string SpendingLimitsCurrency { get; set; }
}
}
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 CardholderAuthorizationControlsSpendingLimitOptions : 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; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ namespace Stripe.Issuing

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

/// <summary>
/// The cardholder’s billing address.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ public CardholderServiceTest(

this.createOptions = new CardholderCreateOptions
{
AuthorizationControls = new CardholderAuthorizationControlsOptions
{
SpendingLimits = new List<CardholderAuthorizationControlsSpendingLimitOptions>
{
new CardholderAuthorizationControlsSpendingLimitOptions
{
Amount = 1000,
Categories = new List<string>
{
"financial_institutions",
},
Interval = "all_time",
},
},
},
Billing = new BillingOptions
{
Address = new AddressOptions
Expand Down