-
Notifications
You must be signed in to change notification settings - Fork 368
/
Copy pathSession.java
635 lines (542 loc) · 21.6 KB
/
Session.java
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
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
// File generated from our OpenAPI spec
package com.stripe.model.checkout;
import com.google.gson.annotations.SerializedName;
import com.stripe.Stripe;
import com.stripe.exception.StripeException;
import com.stripe.model.Customer;
import com.stripe.model.ExpandableField;
import com.stripe.model.HasId;
import com.stripe.model.LineItem;
import com.stripe.model.LineItemCollection;
import com.stripe.model.PaymentIntent;
import com.stripe.model.SetupIntent;
import com.stripe.model.ShippingDetails;
import com.stripe.model.StripeObject;
import com.stripe.model.Subscription;
import com.stripe.net.ApiResource;
import com.stripe.net.RequestOptions;
import com.stripe.param.checkout.SessionCreateParams;
import com.stripe.param.checkout.SessionListLineItemsParams;
import com.stripe.param.checkout.SessionListParams;
import com.stripe.param.checkout.SessionRetrieveParams;
import java.util.List;
import java.util.Map;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public class Session extends ApiResource implements HasId {
/** Enables user redeemable promotion codes. */
@SerializedName("allow_promotion_codes")
Boolean allowPromotionCodes;
/** Total of all items before discounts or taxes are applied. */
@SerializedName("amount_subtotal")
Long amountSubtotal;
/** Total of all items after discounts and taxes are applied. */
@SerializedName("amount_total")
Long amountTotal;
@SerializedName("automatic_tax")
AutomaticTax automaticTax;
/**
* Describes whether Checkout should collect the customer's billing address.
*
* <p>One of {@code auto}, or {@code required}.
*/
@SerializedName("billing_address_collection")
String billingAddressCollection;
/**
* The URL the customer will be directed to if they decide to cancel payment and return to your
* website.
*/
@SerializedName("cancel_url")
String cancelUrl;
/**
* 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.
*/
@SerializedName("client_reference_id")
String clientReferenceId;
/**
* 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>.
*/
@SerializedName("currency")
String currency;
/**
* The ID of the customer for this Session. For Checkout Sessions in {@code payment} or {@code
* subscription} 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.
*/
@SerializedName("customer")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<Customer> customer;
/**
* The customer details including the customer's tax exempt status and the customer's tax IDs.
* Only present on Sessions in {@code payment} or {@code subscription} mode.
*/
@SerializedName("customer_details")
CustomerDetails customerDetails;
/**
* 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 {@code customer} attribute.
*/
@SerializedName("customer_email")
String customerEmail;
/** Unique identifier for the object. Used to pass to {@code redirectToCheckout} in Stripe.js. */
@Getter(onMethod_ = {@Override})
@SerializedName("id")
String id;
/** The line items purchased by the customer. */
@SerializedName("line_items")
LineItemCollection lineItems;
/**
* Has the value {@code true} if the object exists in live mode or the value {@code false} if the
* object exists in test mode.
*/
@SerializedName("livemode")
Boolean livemode;
/**
* The IETF language tag of the locale Checkout is displayed in. If blank or {@code auto}, the
* browser's locale is used.
*
* <p>One of {@code auto}, {@code bg}, {@code cs}, {@code da}, {@code de}, {@code el}, {@code en},
* {@code en-GB}, {@code es}, {@code es-419}, {@code et}, {@code fi}, {@code fr}, {@code fr-CA},
* {@code hr}, {@code hu}, {@code id}, {@code it}, {@code ja}, {@code ko}, {@code lt}, {@code lv},
* {@code ms}, {@code mt}, {@code nb}, {@code nl}, {@code pl}, {@code pt}, {@code pt-BR}, {@code
* ro}, {@code ru}, {@code sk}, {@code sl}, {@code sv}, {@code th}, {@code tr}, {@code vi}, {@code
* zh}, {@code zh-HK}, or {@code zh-TW}.
*/
@SerializedName("locale")
String locale;
/**
* 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.
*/
@SerializedName("metadata")
Map<String, String> metadata;
/**
* The mode of the Checkout Session.
*
* <p>One of {@code payment}, {@code setup}, or {@code subscription}.
*/
@SerializedName("mode")
String mode;
/**
* String representing the object's type. Objects of the same type share the same value.
*
* <p>Equal to {@code checkout.session}.
*/
@SerializedName("object")
String object;
/** The ID of the PaymentIntent for Checkout Sessions in {@code payment} mode. */
@SerializedName("payment_intent")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<PaymentIntent> paymentIntent;
/**
* Payment-method-specific configuration for the PaymentIntent or SetupIntent of this
* CheckoutSession.
*/
@SerializedName("payment_method_options")
PaymentMethodOptions paymentMethodOptions;
/**
* A list of the types of payment methods (e.g. card) this Checkout Session is allowed to accept.
*/
@SerializedName("payment_method_types")
List<String> paymentMethodTypes;
/**
* The payment status of the Checkout Session, one of {@code paid}, {@code unpaid}, or {@code
* no_payment_required}. You can use this value to decide when to fulfill your customer's order.
*/
@SerializedName("payment_status")
String paymentStatus;
/** The ID of the SetupIntent for Checkout Sessions in {@code setup} mode. */
@SerializedName("setup_intent")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<SetupIntent> setupIntent;
/** Shipping information for this Checkout Session. */
@SerializedName("shipping")
ShippingDetails shipping;
/**
* When set, provides configuration for Checkout to collect a shipping address from a customer.
*/
@SerializedName("shipping_address_collection")
ShippingAddressCollection shippingAddressCollection;
/**
* Describes the type of transaction being performed by Checkout in order to customize relevant
* text on the page, such as the submit button. {@code submit_type} can only be specified on
* Checkout Sessions in {@code payment} mode, but not Checkout Sessions in {@code subscription} or
* {@code setup} mode.
*
* <p>One of {@code auto}, {@code book}, {@code donate}, or {@code pay}.
*/
@SerializedName("submit_type")
String submitType;
/** The ID of the subscription for Checkout Sessions in {@code subscription} mode. */
@SerializedName("subscription")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<Subscription> subscription;
/**
* The URL the customer will be directed to after the payment or subscription creation is
* successful.
*/
@SerializedName("success_url")
String successUrl;
@SerializedName("tax_id_collection")
TaxIDCollection taxIdCollection;
/** Tax and discount details for the computed total amount. */
@SerializedName("total_details")
TotalDetails totalDetails;
/** The URL to the Checkout Session. */
@SerializedName("url")
String url;
/** Get ID of expandable {@code customer} object. */
public String getCustomer() {
return (this.customer != null) ? this.customer.getId() : null;
}
public void setCustomer(String id) {
this.customer = ApiResource.setExpandableFieldId(id, this.customer);
}
/** Get expanded {@code customer}. */
public Customer getCustomerObject() {
return (this.customer != null) ? this.customer.getExpanded() : null;
}
public void setCustomerObject(Customer expandableObject) {
this.customer = new ExpandableField<Customer>(expandableObject.getId(), expandableObject);
}
/** Get ID of expandable {@code paymentIntent} object. */
public String getPaymentIntent() {
return (this.paymentIntent != null) ? this.paymentIntent.getId() : null;
}
public void setPaymentIntent(String id) {
this.paymentIntent = ApiResource.setExpandableFieldId(id, this.paymentIntent);
}
/** Get expanded {@code paymentIntent}. */
public PaymentIntent getPaymentIntentObject() {
return (this.paymentIntent != null) ? this.paymentIntent.getExpanded() : null;
}
public void setPaymentIntentObject(PaymentIntent expandableObject) {
this.paymentIntent =
new ExpandableField<PaymentIntent>(expandableObject.getId(), expandableObject);
}
/** Get ID of expandable {@code setupIntent} object. */
public String getSetupIntent() {
return (this.setupIntent != null) ? this.setupIntent.getId() : null;
}
public void setSetupIntent(String id) {
this.setupIntent = ApiResource.setExpandableFieldId(id, this.setupIntent);
}
/** Get expanded {@code setupIntent}. */
public SetupIntent getSetupIntentObject() {
return (this.setupIntent != null) ? this.setupIntent.getExpanded() : null;
}
public void setSetupIntentObject(SetupIntent expandableObject) {
this.setupIntent = new ExpandableField<SetupIntent>(expandableObject.getId(), expandableObject);
}
/** Get ID of expandable {@code subscription} object. */
public String getSubscription() {
return (this.subscription != null) ? this.subscription.getId() : null;
}
public void setSubscription(String id) {
this.subscription = ApiResource.setExpandableFieldId(id, this.subscription);
}
/** Get expanded {@code subscription}. */
public Subscription getSubscriptionObject() {
return (this.subscription != null) ? this.subscription.getExpanded() : null;
}
public void setSubscriptionObject(Subscription expandableObject) {
this.subscription =
new ExpandableField<Subscription>(expandableObject.getId(), expandableObject);
}
/** Returns a list of Checkout Sessions. */
public static SessionCollection list(Map<String, Object> params) throws StripeException {
return list(params, (RequestOptions) null);
}
/** Returns a list of Checkout Sessions. */
public static SessionCollection list(Map<String, Object> params, RequestOptions options)
throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/checkout/sessions");
return ApiResource.requestCollection(url, params, SessionCollection.class, options);
}
/** Returns a list of Checkout Sessions. */
public static SessionCollection list(SessionListParams params) throws StripeException {
return list(params, (RequestOptions) null);
}
/** Returns a list of Checkout Sessions. */
public static SessionCollection list(SessionListParams params, RequestOptions options)
throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/checkout/sessions");
return ApiResource.requestCollection(url, params, SessionCollection.class, options);
}
/** Retrieves a Session object. */
public static Session retrieve(String session) throws StripeException {
return retrieve(session, (Map<String, Object>) null, (RequestOptions) null);
}
/** Retrieves a Session object. */
public static Session retrieve(String session, RequestOptions options) throws StripeException {
return retrieve(session, (Map<String, Object>) null, options);
}
/** Retrieves a Session object. */
public static Session retrieve(String session, Map<String, Object> params, RequestOptions options)
throws StripeException {
String url =
String.format(
"%s%s",
Stripe.getApiBase(),
String.format("/v1/checkout/sessions/%s", ApiResource.urlEncodeId(session)));
return ApiResource.request(ApiResource.RequestMethod.GET, url, params, Session.class, options);
}
/** Retrieves a Session object. */
public static Session retrieve(
String session, SessionRetrieveParams params, RequestOptions options) throws StripeException {
String url =
String.format(
"%s%s",
Stripe.getApiBase(),
String.format("/v1/checkout/sessions/%s", ApiResource.urlEncodeId(session)));
return ApiResource.request(ApiResource.RequestMethod.GET, url, params, Session.class, options);
}
/** Creates a Session object. */
public static Session create(Map<String, Object> params) throws StripeException {
return create(params, (RequestOptions) null);
}
/** Creates a Session object. */
public static Session create(Map<String, Object> params, RequestOptions options)
throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/checkout/sessions");
return ApiResource.request(ApiResource.RequestMethod.POST, url, params, Session.class, options);
}
/** Creates a Session object. */
public static Session create(SessionCreateParams params) throws StripeException {
return create(params, (RequestOptions) null);
}
/** Creates a Session object. */
public static Session create(SessionCreateParams params, RequestOptions options)
throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/checkout/sessions");
return ApiResource.request(ApiResource.RequestMethod.POST, url, params, Session.class, options);
}
/** Returns a list of Line Items */
public LineItemCollection listLineItems(Map<String, Object> params) throws StripeException {
return listLineItems(params, (RequestOptions) null);
}
/** Returns a list of Line Items */
public LineItemCollection listLineItems(Map<String, Object> params, RequestOptions options)
throws StripeException {
String url =
String.format(
"%s%s",
Stripe.getApiBase(),
String.format(
"/v1/checkout/sessions/%s/line_items", ApiResource.urlEncodeId(this.getId())));
return ApiResource.requestCollection(url, params, LineItemCollection.class, options);
}
/** Returns a list of Line Items */
public LineItemCollection listLineItems(SessionListLineItemsParams params)
throws StripeException {
return listLineItems(params, (RequestOptions) null);
}
/** Returns a list of Line Items */
public LineItemCollection listLineItems(SessionListLineItemsParams params, RequestOptions options)
throws StripeException {
String url =
String.format(
"%s%s",
Stripe.getApiBase(),
String.format(
"/v1/checkout/sessions/%s/line_items", ApiResource.urlEncodeId(this.getId())));
return ApiResource.requestCollection(url, params, LineItemCollection.class, options);
}
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class AutomaticTax extends StripeObject {
/** Indicates whether automatic tax is enabled for the session. */
@SerializedName("enabled")
Boolean enabled;
/**
* The status of the most recent automated tax calculation for this session.
*
* <p>One of {@code complete}, {@code failed}, or {@code requires_location_inputs}.
*/
@SerializedName("status")
String status;
}
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class CustomerDetails extends StripeObject {
/** The customer’s email at time of checkout. */
@SerializedName("email")
String email;
/**
* The customer’s tax exempt status at time of checkout.
*
* <p>One of {@code exempt}, {@code none}, or {@code reverse}.
*/
@SerializedName("tax_exempt")
String taxExempt;
/** The customer’s tax IDs at time of checkout. */
@SerializedName("tax_ids")
List<Session.CustomerDetails.TaxID> taxIds;
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class TaxID extends StripeObject {
/**
* The type of the tax ID, one of {@code eu_vat}, {@code br_cnpj}, {@code br_cpf}, {@code
* gb_vat}, {@code nz_gst}, {@code au_abn}, {@code in_gst}, {@code no_vat}, {@code za_vat},
* {@code ch_vat}, {@code mx_rfc}, {@code sg_uen}, {@code ru_inn}, {@code ru_kpp}, {@code
* ca_bn}, {@code hk_br}, {@code es_cif}, {@code tw_vat}, {@code th_vat}, {@code jp_cn},
* {@code jp_rn}, {@code li_uid}, {@code my_itn}, {@code us_ein}, {@code kr_brn}, {@code
* ca_qst}, {@code ca_gst_hst}, {@code ca_pst_bc}, {@code ca_pst_mb}, {@code ca_pst_sk},
* {@code my_sst}, {@code sg_gst}, {@code ae_trn}, {@code cl_tin}, {@code sa_vat}, {@code
* id_npwp}, {@code my_frp}, {@code il_vat}, or {@code unknown}.
*/
@SerializedName("type")
String type;
/** The value of the tax ID. */
@SerializedName("value")
String value;
}
}
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class PaymentMethodOptions extends StripeObject {
@SerializedName("acss_debit")
AcssDebit acssDebit;
@SerializedName("boleto")
Boleto boleto;
@SerializedName("oxxo")
Oxxo oxxo;
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class AcssDebit extends StripeObject {
/**
* Currency supported by the bank account. Returned when the Session is in {@code setup} mode.
*
* <p>One of {@code cad}, or {@code usd}.
*/
@SerializedName("currency")
String currency;
@SerializedName("mandate_options")
MandateOptions mandateOptions;
/**
* Bank account verification method.
*
* <p>One of {@code automatic}, {@code instant}, or {@code microdeposits}.
*/
@SerializedName("verification_method")
String verificationMethod;
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class MandateOptions extends StripeObject {
/** A URL for custom mandate text. */
@SerializedName("custom_mandate_url")
String customMandateUrl;
/**
* Description of the interval. Only required if the 'payment_schedule' parameter is
* 'interval' or 'combined'.
*/
@SerializedName("interval_description")
String intervalDescription;
/**
* Payment schedule for the mandate.
*
* <p>One of {@code combined}, {@code interval}, or {@code sporadic}.
*/
@SerializedName("payment_schedule")
String paymentSchedule;
/**
* Transaction type of the mandate.
*
* <p>One of {@code business}, or {@code personal}.
*/
@SerializedName("transaction_type")
String transactionType;
}
}
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class Boleto extends StripeObject {
/**
* The number of calendar days before a Boleto voucher expires. For example, if you create a
* Boleto voucher on Monday and you set expires_after_days to 2, the Boleto voucher will
* expire on Wednesday at 23:59 America/Sao_Paulo time.
*/
@SerializedName("expires_after_days")
Long expiresAfterDays;
}
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class Oxxo extends StripeObject {
/**
* The number of calendar days before an OXXO invoice expires. For example, if you create an
* OXXO invoice on Monday and you set expires_after_days to 2, the OXXO invoice will expire on
* Wednesday at 23:59 America/Mexico_City time.
*/
@SerializedName("expires_after_days")
Long expiresAfterDays;
}
}
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class ShippingAddressCollection extends StripeObject {
/**
* An array of two-letter ISO country codes representing which countries Checkout should provide
* as options for shipping locations. Unsupported country codes: {@code AS, CX, CC, CU, HM, IR,
* KP, MH, FM, NF, MP, PW, SD, SY, UM, VI}.
*/
@SerializedName("allowed_countries")
List<String> allowedCountries;
}
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class TaxIDCollection extends StripeObject {
/** Indicates whether tax ID collection is enabled for the session. */
@SerializedName("enabled")
Boolean enabled;
}
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class TotalDetails extends StripeObject {
/** This is the sum of all the line item discounts. */
@SerializedName("amount_discount")
Long amountDiscount;
/** This is the sum of all the line item shipping amounts. */
@SerializedName("amount_shipping")
Long amountShipping;
/** This is the sum of all the line item tax amounts. */
@SerializedName("amount_tax")
Long amountTax;
@SerializedName("breakdown")
Breakdown breakdown;
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class Breakdown extends StripeObject {
/** The aggregated line item discounts. */
@SerializedName("discounts")
List<LineItem.Discount> discounts;
/** The aggregated line item tax amounts by rate. */
@SerializedName("taxes")
List<LineItem.Tax> taxes;
}
}
}