Skip to content

Commit

Permalink
Merge pull request #1966 from stripe/remi-add-issuing-changes
Browse files Browse the repository at this point in the history
Add support for `SpendingControls` on Issuing `Card` and `Cardholder`
  • Loading branch information
remi-stripe committed Mar 26, 2020
2 parents 33c760e + f730561 commit a24ea5a
Show file tree
Hide file tree
Showing 22 changed files with 337 additions and 57 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Expand Up @@ -5,7 +5,7 @@ environment:
COVERALLS_REPO_TOKEN:
secure: T0PmP8uyzCseacBCDRBlti2y9Tz5DL6fknea0MKWvbPYrzADmLY2/5kOTfYIsPUk
# If you bump this, don't forget to bump `MinimumMockVersion` in `StripeMockFixture.cs` as well.
STRIPE_MOCK_VERSION: 0.83.0
STRIPE_MOCK_VERSION: 0.85.0

deploy:
- provider: NuGet
Expand Down
Expand Up @@ -61,10 +61,7 @@ public class RequestHistory : StripeEntity<RequestHistory>
[JsonProperty("reason")]
public string Reason { get; set; }

/// <summary>
/// When an authorization is declined due to authorization controls, this list contains
/// details about the authorization controls that were violated. Otherwise, it is empty.
/// </summary>
[Obsolete]
[JsonProperty("violated_authorization_controls")]
public List<AuthorizationRequestHistoryViolatedAuthorizationControl> ViolatedAuthorizationControls { get; set; }
}
Expand Down
12 changes: 8 additions & 4 deletions src/Stripe.net/Entities/Issuing/Cardholders/Cardholder.cs
Expand Up @@ -19,9 +19,7 @@ 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>
[Obsolete("Use SpendingControls instead.")]
[JsonProperty("authorization_controls")]
public CardholderAuthorizationControls AuthorizationControls { get; set; }

Expand Down Expand Up @@ -56,7 +54,7 @@ public class Cardholder : StripeEntity<Cardholder>, IHasId, IHasMetadata, IHasOb
[JsonProperty("individual")]
public CardholderIndividual Individual { get; set; }

[Obsolete("This property is considered deprecated.")]
[Obsolete]
[JsonProperty("is_default")]
public bool IsDefault { get; set; }

Expand Down Expand Up @@ -91,6 +89,12 @@ public class Cardholder : StripeEntity<Cardholder>, IHasId, IHasMetadata, IHasOb
[JsonProperty("requirements")]
public CardholderRequirements Requirements { get; set; }

/// <summary>
/// Spending rules that give you control over how your cardholders can make charges.
/// </summary>
[JsonProperty("spending_controls")]
public CardholderSpendingControls SpendingControls { get; set; }

/// <summary>
/// One of <c>active</c>, <c>inactive</c>, or <c>blocked</c>.
/// </summary>
Expand Down
@@ -0,0 +1,32 @@
namespace Stripe
{
using System.Collections.Generic;
using Newtonsoft.Json;

public class CardholderSpendingControls : StripeEntity<CardholderSpendingControls>
{
/// <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<CardholderSpendingControlsSpendingLimit> SpendingLimits { get; set; }

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

public class CardholderSpendingControlsSpendingLimit : StripeEntity<CardholderSpendingControlsSpendingLimit>
{
/// <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; }
}
}
14 changes: 8 additions & 6 deletions src/Stripe.net/Entities/Issuing/Cards/Card.cs
Expand Up @@ -19,9 +19,7 @@ public class Card : StripeEntity<Card>, IHasId, IHasMetadata, IHasObject
[JsonProperty("object")]
public string Object { get; set; }

/// <summary>
/// Spending rules that give you some control over how your cards can be used.
/// </summary>
[Obsolete("Use SpendingControls instead.")]
[JsonProperty("authorization_controls")]
public AuthorizationControls AuthorizationControls { get; set; }

Expand Down Expand Up @@ -81,9 +79,7 @@ public class Card : StripeEntity<Card>, IHasId, IHasMetadata, IHasObject
[JsonProperty("metadata")]
public Dictionary<string, string> Metadata { get; set; }

/// <summary>
/// The name of the cardholder, printed on the card.
/// </summary>
[Obsolete]
[JsonProperty("name")]
public string Name { get; set; }

Expand Down Expand Up @@ -160,6 +156,12 @@ public Card ReplacementFor
[JsonProperty("shipping")]
public CardShipping Shipping { get; set; }

/// <summary>
/// Spending rules that give you some control over how this card can be used.
/// </summary>
[JsonProperty("spending_controls")]
public CardSpendingControls SpendingControls { get; set; }

/// <summary>
/// One of <c>active</c>, <c>inactive</c>, <c>canceled</c>, <c>lost</c>, <c>stolen</c>, or
/// <c>pending</c>.
Expand Down
2 changes: 1 addition & 1 deletion src/Stripe.net/Entities/Issuing/Cards/CardShipping.cs
Expand Up @@ -43,7 +43,7 @@ public class CardShipping : StripeEntity<CardShipping>
public string Status { get; set; }

/// <summary>
/// Shipment speed. One of <c>express</c>, <c>overnight</c>, or
/// Shipment speed. One of <c>express</c>, <c>priority</c>, or
/// <c>standard</c>. Defaults to <c>standard</c>.
/// </summary>
[JsonProperty("service")]
Expand Down
41 changes: 41 additions & 0 deletions src/Stripe.net/Entities/Issuing/Cards/CardSpendingControls.cs
@@ -0,0 +1,41 @@
namespace Stripe.Issuing
{
using System;
using System.Collections.Generic;
using Newtonsoft.Json;

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

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

/// <summary>
/// Maximum count of approved authorizations on this card. Counts all authorizations
/// retroactively.
/// </summary>
[JsonProperty("max_approvals")]
public long? MaxApprovals { get; set; }

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

/// <summary>
/// Currency for the amounts within <see cref="SpendingLimits"/>. Locked to the currency of
/// the card.
/// </summary>
[JsonProperty("spending_limits_currency")]
public string SpendingLimitsCurrency { get; set; }
}
}
@@ -0,0 +1,29 @@
namespace Stripe.Issuing
{
using System;
using System.Collections.Generic;
using Newtonsoft.Json;

public class CardSpendingControlsSpendingLimit : StripeEntity<CardSpendingControlsSpendingLimit>
{
/// <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; }
}
}
2 changes: 2 additions & 0 deletions src/Stripe.net/Services/Issuing/BillingOptions.cs
@@ -1,12 +1,14 @@
namespace Stripe.Issuing
{
using System;
using Newtonsoft.Json;

public class BillingOptions : INestedOptions
{
[JsonProperty("address")]
public AddressOptions Address { get; set; }

[Obsolete]
[JsonProperty("name")]
public string Name { get; set; }
}
Expand Down
Expand Up @@ -6,9 +6,7 @@ namespace Stripe.Issuing

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

Expand Down Expand Up @@ -36,7 +34,7 @@ public class CardholderCreateOptions : BaseOptions, IHasMetadata
[JsonProperty("individual")]
public CardholderIndividualOptions Individual { get; set; }

[Obsolete("This parameter is considered deprecated.")]
[Obsolete]
[JsonProperty("is_default")]
public bool? IsDefault { get; set; }

Expand All @@ -61,6 +59,12 @@ public class CardholderCreateOptions : BaseOptions, IHasMetadata
[JsonProperty("phone_number")]
public string PhoneNumber { get; set; }

/// <summary>
/// Spending controls that give you control over how your cardholders can make charges.
/// </summary>
[JsonProperty("spending_controls")]
public CardholderSpendingControlsOptions SpendingControls { get; set; }

/// <summary>
/// Specifies whether to permit authorizations on this cardholder’s cards. Possible values
/// are <c>active</c> or <c>inactive</c>.
Expand All @@ -69,7 +73,7 @@ public class CardholderCreateOptions : BaseOptions, IHasMetadata
public string Status { get; set; }

/// <summary>
/// The type of cardholder. Possible values are <c>individual</c> or <c>business_entity</c>.
/// The type of cardholder. Possible values are <c>company</c> or <c>individual</c>.
/// </summary>
[JsonProperty("type")]
public string Type { get; set; }
Expand Down
@@ -0,0 +1,32 @@
namespace Stripe.Issuing
{
using System.Collections.Generic;
using Newtonsoft.Json;

public class CardholderSpendingControlsOptions : 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<CardholderSpendingControlsSpendingLimitOptions> SpendingLimits { get; set; }

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

public class CardholderSpendingControlsSpendingLimitOptions : 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; }
}
}

0 comments on commit a24ea5a

Please sign in to comment.