-
Notifications
You must be signed in to change notification settings - Fork 573
/
Copy pathSession.cs
466 lines (406 loc) · 18.5 KB
/
Session.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
// File generated from our OpenAPI spec
namespace Stripe.Checkout
{
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Stripe.Infrastructure;
/// <summary>
/// A Checkout Session represents your customer's session as they pay for one-time purchases
/// or subscriptions through <a
/// href="https://stripe.com/docs/payments/checkout">Checkout</a> or <a
/// href="https://stripe.com/docs/payments/payment-links">Payment Links</a>. We recommend
/// creating a new Session each time your customer attempts to pay.
///
/// Once payment is successful, the Checkout Session will contain a reference to the <a
/// href="https://stripe.com/docs/api/customers">Customer</a>, and either the successful <a
/// href="https://stripe.com/docs/api/payment_intents">PaymentIntent</a> or an active <a
/// href="https://stripe.com/docs/api/subscriptions">Subscription</a>.
///
/// You can create a Checkout Session on your server and pass its ID to the client to begin
/// Checkout.
///
/// Related guide: <a href="https://stripe.com/docs/payments/checkout/api">Checkout Server
/// Quickstart</a>.
/// </summary>
public class Session : StripeEntity<Session>, IHasId, IHasMetadata, IHasObject
{
/// <summary>
/// Unique identifier for the object. Used to pass to <c>redirectToCheckout</c> in
/// Stripe.js.
/// </summary>
[JsonProperty("id")]
public string Id { get; set; }
/// <summary>
/// String representing the object's type. Objects of the same type share the same value.
/// </summary>
[JsonProperty("object")]
public string Object { get; set; }
/// <summary>
/// When set, provides configuration for actions to take if this Checkout Session expires.
/// </summary>
[JsonProperty("after_expiration")]
public SessionAfterExpiration AfterExpiration { get; set; }
/// <summary>
/// Enables user redeemable promotion codes.
/// </summary>
[JsonProperty("allow_promotion_codes")]
public bool? AllowPromotionCodes { get; set; }
/// <summary>
/// Total of all items before discounts or taxes are applied.
/// </summary>
[JsonProperty("amount_subtotal")]
public long? AmountSubtotal { get; set; }
/// <summary>
/// Total of all items after discounts and taxes are applied.
/// </summary>
[JsonProperty("amount_total")]
public long? AmountTotal { get; set; }
[JsonProperty("automatic_tax")]
public SessionAutomaticTax AutomaticTax { get; set; }
/// <summary>
/// Describes whether Checkout should collect the customer's billing address.
/// One of: <c>auto</c>, or <c>required</c>.
/// </summary>
[JsonProperty("billing_address_collection")]
public string BillingAddressCollection { get; set; }
/// <summary>
/// The URL the customer will be directed to if they decide to cancel payment and return to
/// your website.
/// </summary>
[JsonProperty("cancel_url")]
public string CancelUrl { get; set; }
/// <summary>
/// A unique string to reference the Checkout Session. This can be a customer ID, a cart ID,
/// or similar, and can be used to reconcile the Session with your internal systems.
/// </summary>
[JsonProperty("client_reference_id")]
public string ClientReferenceId { get; set; }
/// <summary>
/// Results of <c>consent_collection</c> for this session.
/// </summary>
[JsonProperty("consent")]
public SessionConsent Consent { get; set; }
/// <summary>
/// When set, provides configuration for the Checkout Session to gather active consent from
/// customers.
/// </summary>
[JsonProperty("consent_collection")]
public SessionConsentCollection ConsentCollection { get; set; }
/// <summary>
/// Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency
/// code</a>, in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported
/// currency</a>.
/// </summary>
[JsonProperty("currency")]
public string Currency { get; set; }
#region Expandable Customer
/// <summary>
/// (ID of the Customer)
/// The ID of the customer for this Session. For Checkout Sessions in <c>payment</c> or
/// <c>subscription</c> mode, Checkout will create a new customer object based on
/// information provided during the payment flow unless an existing customer was provided
/// when the Session was created.
/// </summary>
[JsonIgnore]
public string CustomerId
{
get => this.InternalCustomer?.Id;
set => this.InternalCustomer = SetExpandableFieldId(value, this.InternalCustomer);
}
/// <summary>
/// (Expanded)
/// The ID of the customer for this Session. For Checkout Sessions in <c>payment</c> or
/// <c>subscription</c> mode, Checkout will create a new customer object based on
/// information provided during the payment flow unless an existing customer was provided
/// when the Session was created.
///
/// For more information, see the <a href="https://stripe.com/docs/expand">expand documentation</a>.
/// </summary>
[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
/// <summary>
/// Configure whether a Checkout Session creates a Customer when the Checkout Session
/// completes.
/// One of: <c>always</c>, or <c>if_required</c>.
/// </summary>
[JsonProperty("customer_creation")]
public string CustomerCreation { get; set; }
/// <summary>
/// The customer details including the customer's tax exempt status and the customer's tax
/// IDs. Only present on Sessions in <c>payment</c> or <c>subscription</c> mode.
/// </summary>
[JsonProperty("customer_details")]
public SessionCustomerDetails CustomerDetails { get; set; }
/// <summary>
/// If provided, this value will be used when the Customer object is created. If not
/// provided, customers will be asked to enter their email address. Use this parameter to
/// prefill customer data if you already have an email on file. To access information about
/// the customer once the payment flow is complete, use the <c>customer</c> attribute.
/// </summary>
[JsonProperty("customer_email")]
public string CustomerEmail { get; set; }
/// <summary>
/// The timestamp at which the Checkout Session will expire.
/// </summary>
[JsonProperty("expires_at")]
[JsonConverter(typeof(UnixDateTimeConverter))]
public DateTime ExpiresAt { get; set; } = Stripe.Infrastructure.DateTimeUtils.UnixEpoch;
/// <summary>
/// The line items purchased by the customer.
/// </summary>
[JsonProperty("line_items")]
public StripeList<LineItem> LineItems { get; set; }
/// <summary>
/// Has the value <c>true</c> if the object exists in live mode or the value <c>false</c> if
/// the object exists in test mode.
/// </summary>
[JsonProperty("livemode")]
public bool Livemode { get; set; }
/// <summary>
/// The IETF language tag of the locale Checkout is displayed in. If blank or <c>auto</c>,
/// the browser's locale is used.
/// One of: <c>auto</c>, <c>bg</c>, <c>cs</c>, <c>da</c>, <c>de</c>, <c>el</c>, <c>en</c>,
/// <c>en-GB</c>, <c>es</c>, <c>es-419</c>, <c>et</c>, <c>fi</c>, <c>fil</c>, <c>fr</c>,
/// <c>fr-CA</c>, <c>hr</c>, <c>hu</c>, <c>id</c>, <c>it</c>, <c>ja</c>, <c>ko</c>,
/// <c>lt</c>, <c>lv</c>, <c>ms</c>, <c>mt</c>, <c>nb</c>, <c>nl</c>, <c>pl</c>, <c>pt</c>,
/// <c>pt-BR</c>, <c>ro</c>, <c>ru</c>, <c>sk</c>, <c>sl</c>, <c>sv</c>, <c>th</c>,
/// <c>tr</c>, <c>vi</c>, <c>zh</c>, <c>zh-HK</c>, or <c>zh-TW</c>.
/// </summary>
[JsonProperty("locale")]
public string Locale { get; set; }
/// <summary>
/// Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can
/// attach to an object. This can be useful for storing additional information about the
/// object in a structured format.
/// </summary>
[JsonProperty("metadata")]
public Dictionary<string, string> Metadata { get; set; }
/// <summary>
/// The mode of the Checkout Session.
/// One of: <c>payment</c>, <c>setup</c>, or <c>subscription</c>.
/// </summary>
[JsonProperty("mode")]
public string Mode { get; set; }
#region Expandable PaymentIntent
/// <summary>
/// (ID of the PaymentIntent)
/// The ID of the PaymentIntent for Checkout Sessions in <c>payment</c> mode.
/// </summary>
[JsonIgnore]
public string PaymentIntentId
{
get => this.InternalPaymentIntent?.Id;
set => this.InternalPaymentIntent = SetExpandableFieldId(value, this.InternalPaymentIntent);
}
/// <summary>
/// (Expanded)
/// The ID of the PaymentIntent for Checkout Sessions in <c>payment</c> mode.
///
/// For more information, see the <a href="https://stripe.com/docs/expand">expand documentation</a>.
/// </summary>
[JsonIgnore]
public PaymentIntent PaymentIntent
{
get => this.InternalPaymentIntent?.ExpandedObject;
set => this.InternalPaymentIntent = SetExpandableFieldObject(value, this.InternalPaymentIntent);
}
[JsonProperty("payment_intent")]
[JsonConverter(typeof(ExpandableFieldConverter<PaymentIntent>))]
internal ExpandableField<PaymentIntent> InternalPaymentIntent { get; set; }
#endregion
#region Expandable PaymentLink
/// <summary>
/// (ID of the PaymentLink)
/// The ID of the Payment Link that created this Session.
/// </summary>
[JsonIgnore]
public string PaymentLinkId
{
get => this.InternalPaymentLink?.Id;
set => this.InternalPaymentLink = SetExpandableFieldId(value, this.InternalPaymentLink);
}
/// <summary>
/// (Expanded)
/// The ID of the Payment Link that created this Session.
///
/// For more information, see the <a href="https://stripe.com/docs/expand">expand documentation</a>.
/// </summary>
[JsonIgnore]
public PaymentLink PaymentLink
{
get => this.InternalPaymentLink?.ExpandedObject;
set => this.InternalPaymentLink = SetExpandableFieldObject(value, this.InternalPaymentLink);
}
[JsonProperty("payment_link")]
[JsonConverter(typeof(ExpandableFieldConverter<PaymentLink>))]
internal ExpandableField<PaymentLink> InternalPaymentLink { get; set; }
#endregion
/// <summary>
/// Payment-method-specific configuration for the PaymentIntent or SetupIntent of this
/// CheckoutSession.
/// </summary>
[JsonProperty("payment_method_options")]
public SessionPaymentMethodOptions PaymentMethodOptions { get; set; }
/// <summary>
/// A list of the types of payment methods (e.g. card) this Checkout Session is allowed to
/// accept.
/// </summary>
[JsonProperty("payment_method_types")]
public List<string> PaymentMethodTypes { get; set; }
/// <summary>
/// The payment status of the Checkout Session, one of <c>paid</c>, <c>unpaid</c>, or
/// <c>no_payment_required</c>. You can use this value to decide when to fulfill your
/// customer's order.
/// One of: <c>no_payment_required</c>, <c>paid</c>, or <c>unpaid</c>.
/// </summary>
[JsonProperty("payment_status")]
public string PaymentStatus { get; set; }
[JsonProperty("phone_number_collection")]
public SessionPhoneNumberCollection PhoneNumberCollection { get; set; }
/// <summary>
/// The ID of the original expired Checkout Session that triggered the recovery flow.
/// </summary>
[JsonProperty("recovered_from")]
public string RecoveredFrom { get; set; }
#region Expandable SetupIntent
/// <summary>
/// (ID of the SetupIntent)
/// The ID of the SetupIntent for Checkout Sessions in <c>setup</c> mode.
/// </summary>
[JsonIgnore]
public string SetupIntentId
{
get => this.InternalSetupIntent?.Id;
set => this.InternalSetupIntent = SetExpandableFieldId(value, this.InternalSetupIntent);
}
/// <summary>
/// (Expanded)
/// The ID of the SetupIntent for Checkout Sessions in <c>setup</c> mode.
///
/// For more information, see the <a href="https://stripe.com/docs/expand">expand documentation</a>.
/// </summary>
[JsonIgnore]
public SetupIntent SetupIntent
{
get => this.InternalSetupIntent?.ExpandedObject;
set => this.InternalSetupIntent = SetExpandableFieldObject(value, this.InternalSetupIntent);
}
[JsonProperty("setup_intent")]
[JsonConverter(typeof(ExpandableFieldConverter<SetupIntent>))]
internal ExpandableField<SetupIntent> InternalSetupIntent { get; set; }
#endregion
/// <summary>
/// Shipping information for this Checkout Session.
/// </summary>
[JsonProperty("shipping")]
public Shipping Shipping { get; set; }
/// <summary>
/// When set, provides configuration for Checkout to collect a shipping address from a
/// customer.
/// </summary>
[JsonProperty("shipping_address_collection")]
public SessionShippingAddressCollection ShippingAddressCollection { get; set; }
/// <summary>
/// The shipping rate options applied to this Session.
/// </summary>
[JsonProperty("shipping_options")]
public List<SessionShippingOption> ShippingOptions { get; set; }
#region Expandable ShippingRate
/// <summary>
/// (ID of the ShippingRate)
/// The ID of the ShippingRate for Checkout Sessions in <c>payment</c> mode.
/// </summary>
[JsonIgnore]
public string ShippingRateId
{
get => this.InternalShippingRate?.Id;
set => this.InternalShippingRate = SetExpandableFieldId(value, this.InternalShippingRate);
}
/// <summary>
/// (Expanded)
/// The ID of the ShippingRate for Checkout Sessions in <c>payment</c> mode.
///
/// For more information, see the <a href="https://stripe.com/docs/expand">expand documentation</a>.
/// </summary>
[JsonIgnore]
public ShippingRate ShippingRate
{
get => this.InternalShippingRate?.ExpandedObject;
set => this.InternalShippingRate = SetExpandableFieldObject(value, this.InternalShippingRate);
}
[JsonProperty("shipping_rate")]
[JsonConverter(typeof(ExpandableFieldConverter<ShippingRate>))]
internal ExpandableField<ShippingRate> InternalShippingRate { get; set; }
#endregion
/// <summary>
/// The status of the Checkout Session, one of <c>open</c>, <c>complete</c>, or
/// <c>expired</c>.
/// One of: <c>complete</c>, <c>expired</c>, or <c>open</c>.
/// </summary>
[JsonProperty("status")]
public string Status { get; set; }
/// <summary>
/// Describes the type of transaction being performed by Checkout in order to customize
/// relevant text on the page, such as the submit button. <c>submit_type</c> can only be
/// specified on Checkout Sessions in <c>payment</c> mode, but not Checkout Sessions in
/// <c>subscription</c> or <c>setup</c> mode.
/// One of: <c>auto</c>, <c>book</c>, <c>donate</c>, or <c>pay</c>.
/// </summary>
[JsonProperty("submit_type")]
public string SubmitType { get; set; }
#region Expandable Subscription
/// <summary>
/// (ID of the Subscription)
/// The ID of the subscription for Checkout Sessions in <c>subscription</c> mode.
/// </summary>
[JsonIgnore]
public string SubscriptionId
{
get => this.InternalSubscription?.Id;
set => this.InternalSubscription = SetExpandableFieldId(value, this.InternalSubscription);
}
/// <summary>
/// (Expanded)
/// The ID of the subscription for Checkout Sessions in <c>subscription</c> mode.
///
/// For more information, see the <a href="https://stripe.com/docs/expand">expand documentation</a>.
/// </summary>
[JsonIgnore]
public Subscription Subscription
{
get => this.InternalSubscription?.ExpandedObject;
set => this.InternalSubscription = SetExpandableFieldObject(value, this.InternalSubscription);
}
[JsonProperty("subscription")]
[JsonConverter(typeof(ExpandableFieldConverter<Subscription>))]
internal ExpandableField<Subscription> InternalSubscription { get; set; }
#endregion
/// <summary>
/// The URL the customer will be directed to after the payment or subscription creation is
/// successful.
/// </summary>
[JsonProperty("success_url")]
public string SuccessUrl { get; set; }
[JsonProperty("tax_id_collection")]
public SessionTaxIdCollection TaxIdCollection { get; set; }
/// <summary>
/// Tax and discount details for the computed total amount.
/// </summary>
[JsonProperty("total_details")]
public SessionTotalDetails TotalDetails { get; set; }
/// <summary>
/// The URL to the Checkout Session.
/// </summary>
[JsonProperty("url")]
public string Url { get; set; }
}
}