Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for the
SetupIntent
resource and APIs
- Loading branch information
1 parent
0c1b1ba
commit 8818fe2
Showing
17 changed files
with
619 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
namespace Stripe | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
using Stripe.Infrastructure; | ||
|
||
public class SetupIntent : StripeEntity<SetupIntent>, IHasId, IHasMetadata, IHasObject | ||
{ | ||
[JsonProperty("id")] | ||
public string Id { get; set; } | ||
|
||
[JsonProperty("object")] | ||
public string Object { get; set; } | ||
|
||
#region Expandable Application | ||
[JsonIgnore] | ||
public string ApplicationId | ||
{ | ||
get => this.InternalApplication?.Id; | ||
set => this.InternalApplication = SetExpandableFieldId(value, this.InternalApplication); | ||
} | ||
|
||
[JsonIgnore] | ||
public Application Application | ||
{ | ||
get => this.InternalApplication?.ExpandedObject; | ||
set => this.InternalApplication = SetExpandableFieldObject(value, this.InternalApplication); | ||
} | ||
|
||
[JsonProperty("application")] | ||
[JsonConverter(typeof(ExpandableFieldConverter<Application>))] | ||
internal ExpandableField<Application> InternalApplication { get; set; } | ||
#endregion | ||
|
||
[JsonProperty("cancellation_reason")] | ||
public string CancellationReason { get; set; } | ||
|
||
[JsonProperty("client_secret")] | ||
public string ClientSecret { get; set; } | ||
|
||
[JsonProperty("created")] | ||
[JsonConverter(typeof(DateTimeConverter))] | ||
public DateTime? Created { get; set; } | ||
|
||
#region Expandable Customer | ||
[JsonIgnore] | ||
public string CustomerId | ||
{ | ||
get => this.InternalCustomer?.Id; | ||
set => this.InternalCustomer = SetExpandableFieldId(value, this.InternalCustomer); | ||
} | ||
|
||
[JsonIgnore] | ||
public Customer Customer | ||
{ | ||
get => this.InternalCustomer?.ExpandedObject; | ||
set => this.InternalCustomer = SetExpandableFieldObject(value, this.InternalCustomer); | ||
} | ||
|
||
[JsonProperty("customer")] | ||
[JsonConverter(typeof(ExpandableFieldConverter<Customer>))] | ||
internal ExpandableField<Customer> InternalCustomer { get; set; } | ||
#endregion | ||
|
||
[JsonProperty("description")] | ||
public string Description { get; set; } | ||
|
||
[JsonProperty("last_setup_error")] | ||
public StripeError LastSetupError { get; set; } | ||
|
||
[JsonProperty("livemode")] | ||
public bool Livemode { get; set; } | ||
|
||
[JsonProperty("metadata")] | ||
public Dictionary<string, string> Metadata { get; set; } | ||
|
||
[JsonProperty("next_action")] | ||
public PaymentIntentNextAction NextAction { get; set; } | ||
|
||
#region Expandable OnBehalfOf (Account) | ||
[JsonIgnore] | ||
public string OnBehalfOfId | ||
{ | ||
get => this.InternalOnBehalfOf?.Id; | ||
set => this.InternalOnBehalfOf = SetExpandableFieldId(value, this.InternalOnBehalfOf); | ||
} | ||
|
||
[JsonIgnore] | ||
public Account OnBehalfOf | ||
{ | ||
get => this.InternalOnBehalfOf?.ExpandedObject; | ||
set => this.InternalOnBehalfOf = SetExpandableFieldObject(value, this.InternalOnBehalfOf); | ||
} | ||
|
||
[JsonProperty("on_behalf_of")] | ||
[JsonConverter(typeof(ExpandableFieldConverter<Account>))] | ||
internal ExpandableField<Account> InternalOnBehalfOf { get; set; } | ||
#endregion | ||
|
||
#region Expandable PaymentMethod | ||
[JsonIgnore] | ||
public string PaymentMethodId | ||
{ | ||
get => this.InternalPaymentMethod?.Id; | ||
set => this.InternalPaymentMethod = SetExpandableFieldId(value, this.InternalPaymentMethod); | ||
} | ||
|
||
[JsonIgnore] | ||
public PaymentMethod PaymentMethod | ||
{ | ||
get => this.InternalPaymentMethod?.ExpandedObject; | ||
set => this.InternalPaymentMethod = SetExpandableFieldObject(value, this.InternalPaymentMethod); | ||
} | ||
|
||
[JsonProperty("payment_method")] | ||
[JsonConverter(typeof(ExpandableFieldConverter<PaymentMethod>))] | ||
internal ExpandableField<PaymentMethod> InternalPaymentMethod { get; set; } | ||
#endregion | ||
|
||
[JsonProperty("payment_method_types")] | ||
public List<string> PaymentMethodTypes { get; set; } | ||
|
||
[JsonProperty("status")] | ||
public string Status { get; set; } | ||
|
||
[JsonProperty("usage")] | ||
public string Usage { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/Stripe.net/Services/SetupIntents/SetupIntentCancelOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Stripe | ||
{ | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
|
||
public class SetupIntentCancelOptions : BaseOptions | ||
{ | ||
[JsonProperty("cancellation_reason")] | ||
public string CancellationReason { get; set; } | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/Stripe.net/Services/SetupIntents/SetupIntentConfirmOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace Stripe | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
|
||
public class SetupIntentConfirmOptions : BaseOptions | ||
{ | ||
/// <summary> | ||
/// The client secret of the SetupIntent. Required if a publishable key is used to | ||
/// confirm the setup intent. | ||
/// </summary> | ||
[JsonProperty("client_secret")] | ||
public string ClientSecret { get; set; } | ||
|
||
[JsonProperty("payment_method")] | ||
public string PaymentMethodId { get; set; } | ||
|
||
[JsonProperty("return_url")] | ||
public string ReturnUrl { get; set; } | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/Stripe.net/Services/SetupIntents/SetupIntentCreateOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace Stripe | ||
{ | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
|
||
public class SetupIntentCreateOptions : BaseOptions | ||
{ | ||
[JsonProperty("customer")] | ||
public string CustomerId { get; set; } | ||
|
||
[JsonProperty("description")] | ||
public string Description { get; set; } | ||
|
||
[JsonProperty("metadata")] | ||
public Dictionary<string, string> Metadata { get; set; } | ||
|
||
[JsonProperty("on_behalf_of")] | ||
public string OnBehalfOf { get; set; } | ||
|
||
[JsonProperty("payment_method")] | ||
public string PaymentMethodId { get; set; } | ||
|
||
[JsonProperty("payment_method_types")] | ||
public List<string> PaymentMethodTypes { get; set; } | ||
|
||
[JsonProperty("usage")] | ||
public string Usage { get; set; } | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/Stripe.net/Services/SetupIntents/SetupIntentGetOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace Stripe | ||
{ | ||
using Newtonsoft.Json; | ||
|
||
public class SetupIntentGetOptions : BaseOptions | ||
{ | ||
/// <summary> | ||
/// The client secret of the SetupIntent. Required if a publishable key is used to | ||
/// retrieve the setup intent. | ||
/// </summary> | ||
[JsonProperty("client_secret")] | ||
public string ClientSecret { get; set; } | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Stripe.net/Services/SetupIntents/SetupIntentListOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Stripe | ||
{ | ||
using Newtonsoft.Json; | ||
|
||
public class SetupIntentListOptions : ListOptions | ||
{ | ||
[JsonProperty("customer")] | ||
public string CustomerId { get; set; } | ||
} | ||
} |
92 changes: 92 additions & 0 deletions
92
src/Stripe.net/Services/SetupIntents/SetupIntentService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
namespace Stripe | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Net.Http; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
public class SetupIntentService : Service<SetupIntent>, | ||
ICreatable<SetupIntent, SetupIntentCreateOptions>, | ||
IListable<SetupIntent, SetupIntentListOptions>, | ||
IRetrievable<SetupIntent, SetupIntentGetOptions>, | ||
IUpdatable<SetupIntent, SetupIntentUpdateOptions> | ||
{ | ||
public SetupIntentService() | ||
: base(null) | ||
{ | ||
} | ||
|
||
public SetupIntentService(IStripeClient client) | ||
: base(client) | ||
{ | ||
} | ||
|
||
public override string BasePath => "/v1/setup_intents"; | ||
|
||
public virtual SetupIntent Cancel(string paymentIntentId, SetupIntentCancelOptions options, RequestOptions requestOptions = null) | ||
{ | ||
return this.Request(HttpMethod.Post, $"{this.InstanceUrl(paymentIntentId)}/cancel", options, requestOptions); | ||
} | ||
|
||
public virtual Task<SetupIntent> CancelAsync(string paymentIntentId, SetupIntentCancelOptions options, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
return this.RequestAsync(HttpMethod.Post, $"{this.InstanceUrl(paymentIntentId)}/cancel", options, requestOptions, cancellationToken); | ||
} | ||
|
||
public virtual SetupIntent Confirm(string paymentIntentId, SetupIntentConfirmOptions options, RequestOptions requestOptions = null) | ||
{ | ||
return this.Request(HttpMethod.Post, $"{this.InstanceUrl(paymentIntentId)}/confirm", options, requestOptions); | ||
} | ||
|
||
public virtual Task<SetupIntent> ConfirmAsync(string paymentIntentId, SetupIntentConfirmOptions options, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
return this.RequestAsync(HttpMethod.Post, $"{this.InstanceUrl(paymentIntentId)}/confirm", options, requestOptions, cancellationToken); | ||
} | ||
|
||
public virtual SetupIntent Create(SetupIntentCreateOptions options, RequestOptions requestOptions = null) | ||
{ | ||
return this.CreateEntity(options, requestOptions); | ||
} | ||
|
||
public virtual Task<SetupIntent> CreateAsync(SetupIntentCreateOptions options, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
return this.CreateEntityAsync(options, requestOptions, cancellationToken); | ||
} | ||
|
||
public virtual SetupIntent Get(string paymentIntentId, SetupIntentGetOptions options = null, RequestOptions requestOptions = null) | ||
{ | ||
return this.GetEntity(paymentIntentId, options, requestOptions); | ||
} | ||
|
||
public virtual Task<SetupIntent> GetAsync(string paymentIntentId, SetupIntentGetOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
return this.GetEntityAsync(paymentIntentId, options, requestOptions, cancellationToken); | ||
} | ||
|
||
public virtual StripeList<SetupIntent> List(SetupIntentListOptions options = null, RequestOptions requestOptions = null) | ||
{ | ||
return this.ListEntities(options, requestOptions); | ||
} | ||
|
||
public virtual Task<StripeList<SetupIntent>> ListAsync(SetupIntentListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
return this.ListEntitiesAsync(options, requestOptions, cancellationToken); | ||
} | ||
|
||
public virtual IEnumerable<SetupIntent> ListAutoPaging(SetupIntentListOptions options = null, RequestOptions requestOptions = null) | ||
{ | ||
return this.ListEntitiesAutoPaging(options, requestOptions); | ||
} | ||
|
||
public virtual SetupIntent Update(string paymentIntentId, SetupIntentUpdateOptions options, RequestOptions requestOptions = null) | ||
{ | ||
return this.UpdateEntity(paymentIntentId, options, requestOptions); | ||
} | ||
|
||
public virtual Task<SetupIntent> UpdateAsync(string paymentIntentId, SetupIntentUpdateOptions options, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
return this.UpdateEntityAsync(paymentIntentId, options, requestOptions, cancellationToken); | ||
} | ||
} | ||
} |
Oops, something went wrong.