/
Session.java
1783 lines (1582 loc) · 68.1 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
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// 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.Address;
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.PaymentLink;
import com.stripe.model.SetupIntent;
import com.stripe.model.ShippingDetails;
import com.stripe.model.ShippingRate;
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.SessionExpireParams;
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;
/**
* 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.
*
* <p>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>.
*
* <p>You can create a Checkout Session on your server and pass its ID to the client to begin
* Checkout.
*
* <p>Related guide: <a href="https://stripe.com/docs/checkout/quickstart">Checkout Quickstart</a>.
*/
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public class Session extends ApiResource implements HasId {
/** When set, provides configuration for actions to take if this Checkout Session expires. */
@SerializedName("after_expiration")
AfterExpiration afterExpiration;
/** 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;
/** Results of {@code consent_collection} for this session. */
@SerializedName("consent")
Consent consent;
/**
* When set, provides configuration for the Checkout Session to gather active consent from
* customers.
*/
@SerializedName("consent_collection")
ConsentCollection consentCollection;
/**
* 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;
/**
* Configure whether a Checkout Session creates a Customer when the Checkout Session completes.
*
* <p>One of {@code always}, or {@code if_required}.
*/
@SerializedName("customer_creation")
String customerCreation;
/**
* The customer details including the customer's tax exempt status and the customer's tax IDs.
* Only the customer's email is present on Sessions in {@code setup} 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;
/** The timestamp at which the Checkout Session will expire. */
@SerializedName("expires_at")
Long expiresAt;
/** 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 fil}, {@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;
/** The ID of the Payment Link that created this Session. */
@SerializedName("payment_link")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<PaymentLink> paymentLink;
/**
* Configure whether a Checkout Session should collect a payment method.
*
* <p>One of {@code always}, or {@code if_required}.
*/
@SerializedName("payment_method_collection")
String paymentMethodCollection;
/**
* 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;
@SerializedName("phone_number_collection")
PhoneNumberCollection phoneNumberCollection;
/** The ID of the original expired Checkout Session that triggered the recovery flow. */
@SerializedName("recovered_from")
String recoveredFrom;
/** 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;
/**
* When set, provides configuration for Checkout to collect a shipping address from a customer.
*/
@SerializedName("shipping_address_collection")
ShippingAddressCollection shippingAddressCollection;
/** The details of the customer cost of shipping, including the customer chosen ShippingRate. */
@SerializedName("shipping_cost")
ShippingCost shippingCost;
/** Shipping information for this Checkout Session. */
@SerializedName("shipping_details")
ShippingDetails shippingDetails;
/** The shipping rate options applied to this Session. */
@SerializedName("shipping_options")
List<Session.ShippingOption> shippingOptions;
/**
* The status of the Checkout Session, one of {@code open}, {@code complete}, or {@code expired}.
*/
@SerializedName("status")
String status;
/**
* 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. Redirect customers to this URL to take them to Checkout. If
* you’re using <a href="https://stripe.com/docs/payments/checkout/custom-domains">Custom
* Domains</a>, the URL will use your subdomain. Otherwise, it’ll use {@code checkout.stripe.com.}
*/
@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 paymentLink} object. */
public String getPaymentLink() {
return (this.paymentLink != null) ? this.paymentLink.getId() : null;
}
public void setPaymentLink(String id) {
this.paymentLink = ApiResource.setExpandableFieldId(id, this.paymentLink);
}
/** Get expanded {@code paymentLink}. */
public PaymentLink getPaymentLinkObject() {
return (this.paymentLink != null) ? this.paymentLink.getExpanded() : null;
}
public void setPaymentLinkObject(PaymentLink expandableObject) {
this.paymentLink = new ExpandableField<PaymentLink>(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);
}
/** 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);
}
/**
* A Session can be expired when it is in one of these statuses: <code>open</code>
*
* <p>After it expires, a customer can’t complete a Session and customers loading the Session see
* a message saying the Session is expired.
*/
public Session expire() throws StripeException {
return expire((Map<String, Object>) null, (RequestOptions) null);
}
/**
* A Session can be expired when it is in one of these statuses: <code>open</code>
*
* <p>After it expires, a customer can’t complete a Session and customers loading the Session see
* a message saying the Session is expired.
*/
public Session expire(RequestOptions options) throws StripeException {
return expire((Map<String, Object>) null, options);
}
/**
* A Session can be expired when it is in one of these statuses: <code>open</code>
*
* <p>After it expires, a customer can’t complete a Session and customers loading the Session see
* a message saying the Session is expired.
*/
public Session expire(Map<String, Object> params) throws StripeException {
return expire(params, (RequestOptions) null);
}
/**
* A Session can be expired when it is in one of these statuses: <code>open</code>
*
* <p>After it expires, a customer can’t complete a Session and customers loading the Session see
* a message saying the Session is expired.
*/
public Session expire(Map<String, Object> params, RequestOptions options) throws StripeException {
String url =
String.format(
"%s%s",
Stripe.getApiBase(),
String.format(
"/v1/checkout/sessions/%s/expire", ApiResource.urlEncodeId(this.getId())));
return ApiResource.request(ApiResource.RequestMethod.POST, url, params, Session.class, options);
}
/**
* A Session can be expired when it is in one of these statuses: <code>open</code>
*
* <p>After it expires, a customer can’t complete a Session and customers loading the Session see
* a message saying the Session is expired.
*/
public Session expire(SessionExpireParams params) throws StripeException {
return expire(params, (RequestOptions) null);
}
/**
* A Session can be expired when it is in one of these statuses: <code>open</code>
*
* <p>After it expires, a customer can’t complete a Session and customers loading the Session see
* a message saying the Session is expired.
*/
public Session expire(SessionExpireParams params, RequestOptions options) throws StripeException {
String url =
String.format(
"%s%s",
Stripe.getApiBase(),
String.format(
"/v1/checkout/sessions/%s/expire", ApiResource.urlEncodeId(this.getId())));
return ApiResource.request(ApiResource.RequestMethod.POST, url, params, Session.class, options);
}
/** 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);
}
/**
* When retrieving a Checkout Session, there is an includable <strong>line_items</strong> property
* containing the first handful of those items. There is also a URL where you can retrieve the
* full (paginated) list of line items.
*/
public LineItemCollection listLineItems() throws StripeException {
return listLineItems((Map<String, Object>) null, (RequestOptions) null);
}
/**
* When retrieving a Checkout Session, there is an includable <strong>line_items</strong> property
* containing the first handful of those items. There is also a URL where you can retrieve the
* full (paginated) list of line items.
*/
public LineItemCollection listLineItems(Map<String, Object> params) throws StripeException {
return listLineItems(params, (RequestOptions) null);
}
/**
* When retrieving a Checkout Session, there is an includable <strong>line_items</strong> property
* containing the first handful of those items. There is also a URL where you can retrieve the
* full (paginated) 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);
}
/**
* When retrieving a Checkout Session, there is an includable <strong>line_items</strong> property
* containing the first handful of those items. There is also a URL where you can retrieve the
* full (paginated) list of line items.
*/
public LineItemCollection listLineItems(SessionListLineItemsParams params)
throws StripeException {
return listLineItems(params, (RequestOptions) null);
}
/**
* When retrieving a Checkout Session, there is an includable <strong>line_items</strong> property
* containing the first handful of those items. There is also a URL where you can retrieve the
* full (paginated) 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);
}
/** 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);
}
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class AfterExpiration extends StripeObject {
/** When set, configuration used to recover the Checkout Session on expiry. */
@SerializedName("recovery")
Recovery recovery;
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class Recovery extends StripeObject {
/**
* Enables user redeemable promotion codes on the recovered Checkout Sessions. Defaults to
* {@code false}
*/
@SerializedName("allow_promotion_codes")
Boolean allowPromotionCodes;
/**
* If {@code true}, a recovery url will be generated to recover this Checkout Session if it
* expires before a transaction is completed. It will be attached to the Checkout Session
* object upon expiration.
*/
@SerializedName("enabled")
Boolean enabled;
/** The timestamp at which the recovery URL will expire. */
@SerializedName("expires_at")
Long expiresAt;
/**
* URL that creates a new Checkout Session when clicked that is a copy of this expired
* Checkout Session.
*/
@SerializedName("url")
String url;
}
}
@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 Consent extends StripeObject {
/**
* If {@code opt_in}, the customer consents to receiving promotional communications from the
* merchant about this Checkout Session.
*
* <p>One of {@code opt_in}, or {@code opt_out}.
*/
@SerializedName("promotions")
String promotions;
}
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class ConsentCollection extends StripeObject {
/**
* If set to {@code auto}, enables the collection of customer consent for promotional
* communications. The Checkout Session will determine whether to display an option to opt into
* promotional communication from the merchant depending on the customer's locale. Only
* available to US merchants.
*
* <p>One of {@code auto}, or {@code none}.
*/
@SerializedName("promotions")
String promotions;
}
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class CustomerDetails extends StripeObject {
/**
* The customer's address after a completed Checkout Session. Note: This property is populated
* only for sessions on or after March 30, 2022.
*/
@SerializedName("address")
Address address;
/**
* The email associated with the Customer, if one exists, on the Checkout Session after a
* completed Checkout Session or at time of session expiry. Otherwise, if the customer has
* consented to promotional content, this value is the most recent valid email provided by the
* customer on the Checkout form.
*/
@SerializedName("email")
String email;
/**
* The customer's name after a completed Checkout Session. Note: This property is populated only
* for sessions on or after March 30, 2022.
*/
@SerializedName("name")
String name;
/** The customer's phone number after a completed Checkout Session. */
@SerializedName("phone")
String phone;
/**
* The customer’s tax exempt status after a completed Checkout Session.
*
* <p>One of {@code exempt}, {@code none}, or {@code reverse}.
*/
@SerializedName("tax_exempt")
String taxExempt;
/** The customer’s tax IDs after a completed Checkout Session. */
@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
* eu_oss_vat}, {@code gb_vat}, {@code nz_gst}, {@code au_abn}, {@code au_arn}, {@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}, {@code
* ge_vat}, {@code ua_vat}, {@code is_vat}, {@code bg_uic}, {@code hu_tin}, {@code si_tin}, 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("affirm")
Affirm affirm;
@SerializedName("afterpay_clearpay")
AfterpayClearpay afterpayClearpay;
@SerializedName("alipay")
Alipay alipay;
@SerializedName("au_becs_debit")
AuBecsDebit auBecsDebit;
@SerializedName("bacs_debit")
BacsDebit bacsDebit;
@SerializedName("bancontact")
Bancontact bancontact;
@SerializedName("boleto")
Boleto boleto;
@SerializedName("card")
Card card;
@SerializedName("customer_balance")
CustomerBalance customerBalance;
@SerializedName("eps")
Eps eps;
@SerializedName("fpx")
Fpx fpx;
@SerializedName("giropay")
Giropay giropay;
@SerializedName("grabpay")
GrabPay grabpay;
@SerializedName("ideal")
Ideal ideal;
@SerializedName("klarna")
Klarna klarna;
@SerializedName("konbini")
Konbini konbini;
@SerializedName("oxxo")
Oxxo oxxo;
@SerializedName("p24")
P24 p24;
@SerializedName("paynow")
Paynow paynow;
@SerializedName("pix")
Pix pix;
@SerializedName("sepa_debit")
SepaDebit sepaDebit;
@SerializedName("sofort")
Sofort sofort;
@SerializedName("us_bank_account")
UsBankAccount usBankAccount;
@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;
/**
* Indicates that you intend to make future payments with this PaymentIntent's payment method.
*
* <p>Providing this parameter will <a
* href="https://stripe.com/docs/payments/save-during-payment">attach the payment method</a>
* to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any
* required actions from the user are complete. If no Customer was provided, the payment
* method can still be <a
* href="https://stripe.com/docs/api/payment_methods/attach">attached</a> to a Customer after
* the transaction completes.
*
* <p>When processing card payments, Stripe also uses {@code setup_future_usage} to
* dynamically optimize your payment flow and comply with regional legislation and network
* rules, such as <a href="https://stripe.com/docs/strong-customer-authentication">SCA</a>.
*
* <p>One of {@code none}, {@code off_session}, or {@code on_session}.
*/
@SerializedName("setup_future_usage")
String setupFutureUsage;
/**
* 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;
/**
* List of Stripe products where this mandate can be selected automatically. Returned when
* the Session is in {@code setup} mode.
*/
@SerializedName("default_for")
List<String> defaultFor;
/**
* 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 Affirm extends StripeObject {
/**
* Indicates that you intend to make future payments with this PaymentIntent's payment method.
*
* <p>Providing this parameter will <a
* href="https://stripe.com/docs/payments/save-during-payment">attach the payment method</a>
* to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any
* required actions from the user are complete. If no Customer was provided, the payment
* method can still be <a
* href="https://stripe.com/docs/api/payment_methods/attach">attached</a> to a Customer after
* the transaction completes.
*
* <p>When processing card payments, Stripe also uses {@code setup_future_usage} to
* dynamically optimize your payment flow and comply with regional legislation and network
* rules, such as <a href="https://stripe.com/docs/strong-customer-authentication">SCA</a>.
*
* <p>Equal to {@code none}.
*/
@SerializedName("setup_future_usage")
String setupFutureUsage;
}
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class AfterpayClearpay extends StripeObject {
/**
* Indicates that you intend to make future payments with this PaymentIntent's payment method.
*
* <p>Providing this parameter will <a
* href="https://stripe.com/docs/payments/save-during-payment">attach the payment method</a>
* to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any
* required actions from the user are complete. If no Customer was provided, the payment
* method can still be <a
* href="https://stripe.com/docs/api/payment_methods/attach">attached</a> to a Customer after
* the transaction completes.
*
* <p>When processing card payments, Stripe also uses {@code setup_future_usage} to
* dynamically optimize your payment flow and comply with regional legislation and network
* rules, such as <a href="https://stripe.com/docs/strong-customer-authentication">SCA</a>.
*
* <p>Equal to {@code none}.
*/
@SerializedName("setup_future_usage")
String setupFutureUsage;
}
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class Alipay extends StripeObject {
/**
* Indicates that you intend to make future payments with this PaymentIntent's payment method.
*
* <p>Providing this parameter will <a
* href="https://stripe.com/docs/payments/save-during-payment">attach the payment method</a>
* to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any
* required actions from the user are complete. If no Customer was provided, the payment
* method can still be <a
* href="https://stripe.com/docs/api/payment_methods/attach">attached</a> to a Customer after