Skip to content

Commit 33f1c6d

Browse files
committed
Add support for Subscription Schedule APIs
* Add Subscription Schedule * Add Subscription Schedule Revisions * Add `invoice_settings` on the Customer
1 parent d9c36d6 commit 33f1c6d

34 files changed

+59497
-1
lines changed

src/Stripe.net/Entities/Customers/Customer.cs

+34-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ public class Customer : StripeEntity, IHasId, IHasMetadata, IHasObject
1919
[JsonProperty("account_balance")]
2020
public long AccountBalance { get; set; }
2121

22+
/// <summary>
23+
/// Time at which the object was created. Measured in seconds since the Unix epoch.
24+
/// </summary>
2225
[JsonProperty("created")]
2326
[JsonConverter(typeof(DateTimeConverter))]
2427
public DateTime Created { get; set; }
@@ -74,6 +77,9 @@ internal object InternalDefaultSource
7477
[JsonProperty("delinquent")]
7578
public bool Delinquent { get; set; }
7679

80+
/// <summary>
81+
/// An arbitrary string attached to the object. Often useful for displaying to users.
82+
/// </summary>
7783
[JsonProperty("description")]
7884
public string Description { get; set; }
7985

@@ -83,21 +89,42 @@ internal object InternalDefaultSource
8389
[JsonProperty("discount")]
8490
public Discount Discount { get; set; }
8591

92+
/// <summary>
93+
/// The customer’s email address.
94+
/// </summary>
8695
[JsonProperty("email")]
8796
public string Email { get; set; }
8897

98+
/// <summary>
99+
/// The prefix for the customer used to generate unique invoice numbers.
100+
/// </summary>
89101
[JsonProperty("invoice_prefix")]
90102
public string InvoicePrefix { get; set; }
91103

104+
/// <summary>
105+
/// The customer’s default invoice settings.
106+
/// </summary>
107+
[JsonProperty("invoice_settings")]
108+
public CustomerInvoiceSettings InvoiceSettings { get; set; }
109+
110+
/// <summary>
111+
/// Has the value <code>true</code> if the object exists in live mode or the value
112+
/// <code>false</code> if the object exists in test mode.
113+
/// </summary>
92114
[JsonProperty("livemode")]
93115
public bool Livemode { get; set; }
94116

95117
/// <summary>
96-
/// A set of key/value pairs that you can attach to a customer object. It can be useful for storing additional information about the customer in a structured format
118+
/// A set of key/value pairs that you can attach to a customer object. It can be useful for
119+
/// storing additional information about the customer in a structured format
97120
/// </summary>
98121
[JsonProperty("metadata")]
99122
public Dictionary<string, string> Metadata { get; set; }
100123

124+
/// <summary>
125+
/// Mailing and shipping address for the customer. Appears on invoices emailed to this
126+
/// customer.
127+
/// </summary>
101128
[JsonProperty("shipping")]
102129
public Shipping Shipping { get; set; }
103130

@@ -113,9 +140,15 @@ internal object InternalDefaultSource
113140
[JsonProperty("subscriptions")]
114141
public StripeList<Subscription> Subscriptions { get; set; }
115142

143+
/// <summary>
144+
/// The customer’s tax information. Appears on invoices emailed to this customer.
145+
/// </summary>
116146
[JsonProperty("tax_info")]
117147
public CustomerTaxInfo TaxInfo { get; set; }
118148

149+
/// <summary>
150+
/// Describes the status of looking up the tax ID provided in <code>tax_info</code>.
151+
/// </summary>
119152
[JsonProperty("tax_info_verification")]
120153
public CustomerTaxInfoVerification TaxInfoVerification { get; set; }
121154
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
namespace Stripe
2+
{
3+
using System.Collections.Generic;
4+
using Newtonsoft.Json;
5+
6+
public class CustomerInvoiceSettings : StripeEntity
7+
{
8+
/// <summary>
9+
/// Default custom fields to be displayed on invoices for this customer.
10+
/// </summary>
11+
[JsonProperty("custom_fields")]
12+
public List<InvoiceCustomField> CustomFields { get; set; }
13+
14+
/// <summary>
15+
/// Default footer to be displayed on invoices for this customer.
16+
/// </summary>
17+
[JsonProperty("footer")]
18+
public string Footer { get; set; }
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
namespace Stripe
2+
{
3+
using System;
4+
using System.Collections.Generic;
5+
using Newtonsoft.Json;
6+
using Stripe.Infrastructure;
7+
8+
public class SubscriptionScheduleRevision : StripeEntity, IHasId, IHasObject
9+
{
10+
/// <summary>
11+
/// Unique identifier for the object.
12+
/// </summary>
13+
[JsonProperty("id")]
14+
public string Id { get; set; }
15+
16+
/// <summary>
17+
/// String representing the object’s type. Objects of the same type share the same value.
18+
/// </summary>
19+
[JsonProperty("object")]
20+
public string Object { get; set; }
21+
22+
/// <summary>
23+
/// Time at which the object was created. Measured in seconds since the Unix epoch.
24+
/// </summary>
25+
[JsonProperty("created")]
26+
[JsonConverter(typeof(DateTimeConverter))]
27+
public DateTime? Created { get; set; }
28+
29+
/// <summary>
30+
/// The schedule's default invoice settings.
31+
/// </summary>
32+
[JsonProperty("invoice_settings")]
33+
public SubscriptionScheduleInvoiceSettings InvoiceSettings { get; set; }
34+
35+
/// <summary>
36+
/// Has the value <code>true</code> if the object exists in live mode or the value
37+
/// <code>false</code> if the object exists in test mode.
38+
/// </summary>
39+
[JsonProperty("livemode")]
40+
public bool Livemode { get; set; }
41+
42+
/// <summary>
43+
/// Configuration for the subscription schedule’s phases.
44+
/// </summary>
45+
[JsonProperty("phases")]
46+
public List<SubscriptionSchedulePhase> Phases { get; set; }
47+
48+
/// <summary>
49+
/// ID of the previous subscription schedule revision.
50+
/// </summary>
51+
[JsonProperty("previous_revision")]
52+
public string PreviousRevisionId { get; set; }
53+
54+
/// <summary>
55+
/// Interval and duration at which the subscription schedule renews for when it ends if
56+
/// <code>renewal_behavior</code> is <code>renew</code>.
57+
/// </summary>
58+
[JsonProperty("renewal_behavior")]
59+
public string RenewalBehavior { get; set; }
60+
61+
/// <summary>
62+
/// Interval and duration at which the subscription schedule renews for when it ends if
63+
/// <code>renewal_behavior</code> is <code>renew</code>.
64+
/// </summary>
65+
[JsonProperty("renewal_interval")]
66+
public SubscriptionScheduleRenewalInterval RenewalInterval { get; set; }
67+
68+
/// <summary>
69+
/// ID of the subscription schedule the revision points to.
70+
/// </summary>
71+
[JsonProperty("schedule")]
72+
public string ScheduleId { get; set; }
73+
}
74+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
namespace Stripe
2+
{
3+
using System;
4+
using System.Collections.Generic;
5+
using Newtonsoft.Json;
6+
using Stripe.Infrastructure;
7+
8+
public class SubscriptionSchedule : StripeEntity, IHasId, IHasMetadata, IHasObject
9+
{
10+
/// <summary>
11+
/// Unique identifier for the object.
12+
/// </summary>
13+
[JsonProperty("id")]
14+
public string Id { get; set; }
15+
16+
/// <summary>
17+
/// String representing the object’s type. Objects of the same type share the same value.
18+
/// </summary>
19+
[JsonProperty("object")]
20+
public string Object { get; set; }
21+
22+
/// <summary>
23+
/// One of <see cref="Billing" />. When charging automatically, Stripe will attempt to pay
24+
/// this subscription at the end of the cycle using the default source attached to the
25+
/// customer. When sending an invoice, Stripe will email your customer an invoice with
26+
/// payment instructions.
27+
/// </summary>
28+
[JsonProperty("billing")]
29+
public Billing? Billing { get; set; }
30+
31+
/// <summary>
32+
/// Define thresholds at which an invoice will be sent, and the subscription advanced to a
33+
/// new billing period
34+
/// </summary>
35+
[JsonProperty("billing_thresholds")]
36+
public SubscriptionBillingThresholds BillingThresholds { get; set; }
37+
38+
/// <summary>
39+
/// Time at which the subscription schedule was canceled. Measured in seconds since the
40+
/// Unix epoch.
41+
/// </summary>
42+
[JsonProperty("canceled_at")]
43+
[JsonConverter(typeof(DateTimeConverter))]
44+
public DateTime? CanceledAt { get; set; }
45+
46+
/// <summary>
47+
/// Time at which the subscription schedule was completed. Measured in seconds since the
48+
/// Unix epoch.
49+
/// </summary>
50+
[JsonProperty("completed_at")]
51+
[JsonConverter(typeof(DateTimeConverter))]
52+
public DateTime? CompletedAt { get; set; }
53+
54+
/// <summary>
55+
/// Time at which the object was created. Measured in seconds since the Unix epoch.
56+
/// </summary>
57+
[JsonProperty("created")]
58+
[JsonConverter(typeof(DateTimeConverter))]
59+
public DateTime? Created { get; set; }
60+
61+
/// <summary>
62+
/// Object representing the start and end dates for the current phase of the subscription
63+
/// schedule, if it is <code>active</code>.
64+
/// </summary>
65+
[JsonProperty("current_phase")]
66+
public SubscriptionScheduleCurrentPhase CurrentPhase { get; set; }
67+
68+
// TODO: figure out how we document those
69+
#region Expandable Customer
70+
[JsonIgnore]
71+
public string CustomerId { get; set; }
72+
73+
[JsonIgnore]
74+
public Customer Customer { get; set; }
75+
76+
[JsonProperty("customer")]
77+
internal object InternalCustomer
78+
{
79+
get
80+
{
81+
return this.Customer ?? (object)this.CustomerId;
82+
}
83+
84+
set
85+
{
86+
StringOrObject<Customer>.Map(value, s => this.CustomerId = s, o => this.Customer = o);
87+
}
88+
}
89+
#endregion
90+
91+
/// <summary>
92+
/// The schedule's default invoice settings.
93+
/// </summary>
94+
[JsonProperty("invoice_settings")]
95+
public SubscriptionScheduleInvoiceSettings InvoiceSettings { get; set; }
96+
97+
/// <summary>
98+
/// Has the value <code>true</code> if the object exists in live mode or the value
99+
/// <code>false</code> if the object exists in test mode.
100+
/// </summary>
101+
[JsonProperty("livemode")]
102+
public bool Livemode { get; set; }
103+
104+
/// <summary>
105+
/// A set of key/value pairs that you can attach to a subscription schedule object.
106+
/// </summary>
107+
[JsonProperty("metadata")]
108+
public Dictionary<string, string> Metadata { get; set; }
109+
110+
/// <summary>
111+
/// Configuration for the subscription schedule’s phases.
112+
/// </summary>
113+
[JsonProperty("phases")]
114+
public List<SubscriptionSchedulePhase> Phases { get; set; }
115+
116+
/// <summary>
117+
/// Time at which the subscription schedule was released. Measured in seconds since the
118+
/// Unix epoch.
119+
/// </summary>
120+
[JsonProperty("released_at")]
121+
[JsonConverter(typeof(DateTimeConverter))]
122+
public DateTime? ReleasedAt { get; set; }
123+
124+
/// <summary>
125+
/// ID of the subscription once managed by the subscription schedule (if it is released).
126+
/// </summary>
127+
[JsonProperty("released_subscription")]
128+
public string ReleasedSubscriptionId { get; set; }
129+
130+
/// <summary>
131+
/// Behavior of the subscription schedule and underlying subscription when it ends.
132+
/// </summary>
133+
[JsonProperty("renewal_behavior")]
134+
public string RenewalBehavior { get; set; }
135+
136+
/// <summary>
137+
/// Interval and duration at which the subscription schedule renews for when it ends if
138+
/// <code>renewal_behavior</code> is <code>renew</code>.
139+
/// </summary>
140+
[JsonProperty("renewal_interval")]
141+
public SubscriptionScheduleRenewalInterval RenewalInterval { get; set; }
142+
143+
/// <summary>
144+
/// ID of the current revision of the subscription schedule.
145+
/// </summary>
146+
[JsonProperty("revision")]
147+
public string RevisionId { get; set; }
148+
149+
/// <summary>
150+
/// Possible values are <code>active</code>, <code>canceled</code>, <code>completed</code>,
151+
/// <code>not_started</code>, <code>released</code> and <code>renewal_behavior</code>.
152+
/// </summary>
153+
[JsonProperty("status")]
154+
public string Status { get; set; }
155+
156+
// TODO: figure out how we document those
157+
#region Expandable Subscription
158+
[JsonIgnore]
159+
public string SubscriptionId { get; set; }
160+
161+
[JsonIgnore]
162+
public Subscription Subscription { get; set; }
163+
164+
[JsonProperty("subscription")]
165+
internal object InternalSubscription
166+
{
167+
get
168+
{
169+
return this.Subscription ?? (object)this.SubscriptionId;
170+
}
171+
172+
set
173+
{
174+
StringOrObject<Subscription>.Map(value, s => this.SubscriptionId = s, o => this.Subscription = o);
175+
}
176+
}
177+
#endregion
178+
}
179+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace Stripe
2+
{
3+
using System;
4+
using System.Collections.Generic;
5+
using Newtonsoft.Json;
6+
using Stripe.Infrastructure;
7+
8+
public class SubscriptionScheduleCurrentPhase : StripeEntity
9+
{
10+
/// <summary>
11+
/// The end of the this phase of the subscription schedule.
12+
/// </summary>
13+
[JsonProperty("end_date")]
14+
[JsonConverter(typeof(DateTimeConverter))]
15+
public DateTime? EndDate { get; set; }
16+
17+
/// <summary>
18+
/// The start of this phase of the subscription schedule.
19+
/// </summary>
20+
[JsonProperty("start_date")]
21+
[JsonConverter(typeof(DateTimeConverter))]
22+
public DateTime? StartDate { get; set; }
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace Stripe
2+
{
3+
using System;
4+
using System.Collections.Generic;
5+
using Newtonsoft.Json;
6+
using Stripe.Infrastructure;
7+
8+
public class SubscriptionScheduleInvoiceSettings : StripeEntity
9+
{
10+
/// <summary>
11+
/// The number of days from which the invoice is created until it is due.
12+
/// </summary>
13+
[JsonProperty("days_until_due")]
14+
public long? DaysUntilDue { get; set; }
15+
}
16+
}

0 commit comments

Comments
 (0)