Skip to content

Commit dd7c76f

Browse files
committed
Add support for Subscription Schedule
1 parent d9c36d6 commit dd7c76f

25 files changed

+1222
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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+
[JsonProperty("id")]
11+
public string Id { get; set; }
12+
13+
[JsonProperty("object")]
14+
public string Object { get; set; }
15+
16+
/// <summary>
17+
/// Time at which the object was created. Measured in seconds since the Unix epoch.
18+
/// </summary>
19+
[JsonProperty("created")]
20+
[JsonConverter(typeof(DateTimeConverter))]
21+
public DateTime? Created { get; set; }
22+
23+
/// <summary>
24+
/// TODO: Figure out docs.
25+
/// </summary>
26+
[JsonProperty("footer")]
27+
public SubscriptionScheduleInvoiceSettings InvoiceSettings { get; set; }
28+
29+
/// <summary>
30+
/// Has the value <code>true</code> if the object exists in live mode or the value
31+
/// <code>false</code> if the object exists in test mode.
32+
/// </summary>
33+
[JsonProperty("livemode")]
34+
public bool Livemode { get; set; }
35+
36+
/// <summary>
37+
/// Configuration for the subscription schedule’s phases.
38+
/// </summary>
39+
[JsonProperty("phases")]
40+
public List<SubscriptionSchedulePhase> Phases { get; set; }
41+
42+
/// <summary>
43+
/// TODO: Figure out docs
44+
/// </summary>
45+
[JsonProperty("previous_revision")]
46+
public string PreviousRevisionId { get; set; }
47+
48+
/// <summary>
49+
/// Interval and duration at which the subscription schedule renews for when it ends if
50+
/// <code>renewal_behavior</code> is <code>renew</code>.
51+
/// </summary>
52+
[JsonProperty("renewal_behavior")]
53+
public string RenewalBehavior { get; set; }
54+
55+
/// <summary>
56+
/// Interval and duration at which the subscription schedule renews for when it ends if
57+
/// <code>renewal_behavior</code> is <code>renew</code>.
58+
/// </summary>
59+
[JsonProperty("renewal_interval")]
60+
public SubscriptionScheduleRenewalInterval RenewalInterval { get; set; }
61+
62+
/// <summary>
63+
/// ID of the subscription schedule the revision points to.
64+
/// </summary>
65+
[JsonProperty("schedule")]
66+
public string ScheduleId { get; set; }
67+
}
68+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
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+
[JsonProperty("id")]
11+
public string Id { get; set; }
12+
13+
[JsonProperty("object")]
14+
public string Object { get; set; }
15+
16+
/// <summary>
17+
/// One of <see cref="Billing" />. When charging automatically, Stripe will attempt to pay
18+
/// this subscription at the end of the cycle using the default source attached to the
19+
/// customer. When sending an invoice, Stripe will email your customer an invoice with
20+
/// payment instructions.
21+
/// </summary>
22+
[JsonProperty("billing")]
23+
public Billing? Billing { get; set; }
24+
25+
/// <summary>
26+
/// Define thresholds at which an invoice will be sent, and the subscription advanced to a
27+
/// new billing period
28+
/// </summary>
29+
[JsonProperty("billing_thresholds")]
30+
public SubscriptionBillingThresholds BillingThresholds { get; set; }
31+
32+
/// <summary>
33+
/// Time at which the subscription schedule was canceled. Measured in seconds since the
34+
/// Unix epoch.
35+
/// </summary>
36+
[JsonProperty("canceled_at")]
37+
[JsonConverter(typeof(DateTimeConverter))]
38+
public DateTime? CanceledAt { get; set; }
39+
40+
/// <summary>
41+
/// Time at which the subscription schedule was completed. Measured in seconds since the
42+
/// Unix epoch.
43+
/// </summary>
44+
[JsonProperty("completed_at")]
45+
[JsonConverter(typeof(DateTimeConverter))]
46+
public DateTime? CompletedAt { get; set; }
47+
48+
/// <summary>
49+
/// Time at which the object was created. Measured in seconds since the Unix epoch.
50+
/// </summary>
51+
[JsonProperty("created")]
52+
[JsonConverter(typeof(DateTimeConverter))]
53+
public DateTime? Created { get; set; }
54+
55+
/// <summary>
56+
/// Object representing the start and end dates for the current phase of the subscription
57+
/// schedule, if it is <code>active</code>.
58+
/// </summary>
59+
[JsonProperty("current_phase")]
60+
public SubscriptionScheduleCurrentPhase CurrentPhase { get; set; }
61+
62+
// TODO: figure out how we document those
63+
#region Expandable Customer
64+
[JsonIgnore]
65+
public string CustomerId { get; set; }
66+
67+
[JsonIgnore]
68+
public Customer Customer { get; set; }
69+
70+
[JsonProperty("customer")]
71+
internal object InternalCustomer
72+
{
73+
get
74+
{
75+
return this.Customer ?? (object)this.CustomerId;
76+
}
77+
78+
set
79+
{
80+
StringOrObject<Customer>.Map(value, s => this.CustomerId = s, o => this.Customer = o);
81+
}
82+
}
83+
#endregion
84+
85+
/// <summary>
86+
/// TODO: Figure out docs.
87+
/// </summary>
88+
[JsonProperty("footer")]
89+
public SubscriptionScheduleInvoiceSettings InvoiceSettings { get; set; }
90+
91+
/// <summary>
92+
/// Has the value <code>true</code> if the object exists in live mode or the value
93+
/// <code>false</code> if the object exists in test mode.
94+
/// </summary>
95+
[JsonProperty("livemode")]
96+
public bool Livemode { get; set; }
97+
98+
/// <summary>
99+
/// A set of key/value pairs that you can attach to a subscription schedule object.
100+
/// </summary>
101+
[JsonProperty("metadata")]
102+
public Dictionary<string, string> Metadata { get; set; }
103+
104+
/// <summary>
105+
/// Configuration for the subscription schedule’s phases.
106+
/// </summary>
107+
[JsonProperty("phases")]
108+
public List<SubscriptionSchedulePhase> Phases { get; set; }
109+
110+
/// <summary>
111+
/// Time at which the subscription schedule was released. Measured in seconds since the
112+
/// Unix epoch.
113+
/// </summary>
114+
[JsonProperty("released_at")]
115+
[JsonConverter(typeof(DateTimeConverter))]
116+
public DateTime? ReleasedAt { get; set; }
117+
118+
// TODO: figure out how we document those
119+
#region Expandable ReleasedSubscription
120+
[JsonIgnore]
121+
public string ReleasedSubscriptionId { get; set; }
122+
123+
[JsonIgnore]
124+
public Subscription ReleasedSubscription { get; set; }
125+
126+
[JsonProperty("released_subscription")]
127+
internal object InternalReleasedSubscription
128+
{
129+
get
130+
{
131+
return this.ReleasedSubscription ?? (object)this.ReleasedSubscriptionId;
132+
}
133+
134+
set
135+
{
136+
StringOrObject<Subscription>.Map(value, s => this.ReleasedSubscriptionId = s, o => this.ReleasedSubscription = o);
137+
}
138+
}
139+
#endregion
140+
141+
/// <summary>
142+
/// Behavior of the subscription schedule and underlying subscription when it ends.
143+
/// </summary>
144+
[JsonProperty("renewal_behavior")]
145+
public string RenewalBehavior { get; set; }
146+
147+
/// <summary>
148+
/// Interval and duration at which the subscription schedule renews for when it ends if
149+
/// <code>renewal_behavior</code> is <code>renew</code>.
150+
/// </summary>
151+
[JsonProperty("renewal_interval")]
152+
public SubscriptionScheduleRenewalInterval RenewalInterval { get; set; }
153+
154+
/// <summary>
155+
/// ID of the current revision of the subscription schedule.
156+
/// </summary>
157+
[JsonProperty("revision")]
158+
public string Revision { get; set; }
159+
160+
/// <summary>
161+
/// Possible values are <code>active</code>, <code>canceled</code>, <code>completed</code>,
162+
/// <code>not_started</code>, <code>released</code> and <code>renewal_behavior</code>.
163+
/// </summary>
164+
[JsonProperty("status")]
165+
public string Status { get; set; }
166+
167+
// TODO: figure out how we document those
168+
#region Expandable Subscription
169+
[JsonIgnore]
170+
public string SubscriptionId { get; set; }
171+
172+
[JsonIgnore]
173+
public Subscription Subscription { get; set; }
174+
175+
[JsonProperty("subscription")]
176+
internal object InternalSubscription
177+
{
178+
get
179+
{
180+
return this.Subscription ?? (object)this.SubscriptionId;
181+
}
182+
183+
set
184+
{
185+
StringOrObject<Subscription>.Map(value, s => this.SubscriptionId = s, o => this.Subscription = o);
186+
}
187+
}
188+
#endregion
189+
}
190+
}
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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
namespace Stripe
2+
{
3+
using System;
4+
using System.Collections.Generic;
5+
using Newtonsoft.Json;
6+
using Stripe.Infrastructure;
7+
8+
public class SubscriptionSchedulePhase : StripeEntity
9+
{
10+
/// <summary>
11+
/// A non-negative decimal between 0 and 100, with at most two decimal places. This
12+
/// represents the percentage of the subscription invoice subtotal that will be transferred
13+
/// to the application owner’s Stripe account during this phase of the schedule.
14+
/// </summary>
15+
[JsonProperty("application_fee_percent")]
16+
public decimal? ApplicationFeePercent { get; set; }
17+
18+
// TODO: figure out how we document those
19+
#region Expandable Coupon
20+
[JsonIgnore]
21+
public string CouponId { get; set; }
22+
23+
[JsonIgnore]
24+
public Coupon Coupon { get; set; }
25+
26+
[JsonProperty("coupon")]
27+
internal object InternalCoupon
28+
{
29+
get
30+
{
31+
return this.Coupon ?? (object)this.CouponId;
32+
}
33+
34+
set
35+
{
36+
StringOrObject<Coupon>.Map(value, s => this.CouponId = s, o => this.Coupon = o);
37+
}
38+
}
39+
#endregion
40+
41+
/// <summary>
42+
/// The end of the this phase of the subscription schedule.
43+
/// </summary>
44+
[JsonProperty("end_date")]
45+
[JsonConverter(typeof(DateTimeConverter))]
46+
public DateTime? EndDate { get; set; }
47+
48+
/// <summary>
49+
/// The end of the this phase of the subscription schedule.
50+
/// </summary>
51+
[JsonProperty("plans")]
52+
public List<SubscriptionSchedulePhasePlan> Plans { get; set; }
53+
54+
/// <summary>
55+
/// The start of this phase of the subscription schedule.
56+
/// </summary>
57+
[JsonProperty("start_date")]
58+
[JsonConverter(typeof(DateTimeConverter))]
59+
public DateTime? StartDate { get; set; }
60+
61+
/// <summary>
62+
/// If provided, each invoice created during this phase of the subscription schedule will
63+
/// apply the tax rate, increasing the amount billed to the customer.
64+
/// </summary>
65+
[JsonProperty("tax_percent")]
66+
public decimal? TaxPercent { get; set; }
67+
68+
/// <summary>
69+
/// When the trial ends within the phase.
70+
/// </summary>
71+
[JsonProperty("trial_end")]
72+
[JsonConverter(typeof(DateTimeConverter))]
73+
public DateTime? TrialEnd { get; set; }
74+
}
75+
}

0 commit comments

Comments
 (0)