Class Session

All Implemented Interfaces:
HasId, StripeActiveObject, StripeObjectInterface

public class Session extends ApiResource implements HasId
A Checkout Session represents your customer's session as they pay for one-time purchases or subscriptions through Checkout or Payment Links. 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 Customer, and either the successful PaymentIntent or an active Subscription.

You can create a Checkout Session on your server and redirect to its URL to begin Checkout.

Related guide: Checkout quickstart

  • Constructor Details

    • Session

      public Session()
  • Method Details

    • getCustomer

      public String getCustomer()
      Get ID of expandable customer object.
    • setCustomer

      public void setCustomer(String id)
    • getCustomerObject

      public Customer getCustomerObject()
      Get expanded customer.
    • setCustomerObject

      public void setCustomerObject(Customer expandableObject)
    • getInvoice

      public String getInvoice()
      Get ID of expandable invoice object.
    • setInvoice

      public void setInvoice(String id)
    • getInvoiceObject

      public Invoice getInvoiceObject()
      Get expanded invoice.
    • setInvoiceObject

      public void setInvoiceObject(Invoice expandableObject)
    • getPaymentIntent

      public String getPaymentIntent()
      Get ID of expandable paymentIntent object.
    • setPaymentIntent

      public void setPaymentIntent(String id)
    • getPaymentIntentObject

      public PaymentIntent getPaymentIntentObject()
      Get expanded paymentIntent.
    • setPaymentIntentObject

      public void setPaymentIntentObject(PaymentIntent expandableObject)
    • getPaymentLink

      public String getPaymentLink()
      Get ID of expandable paymentLink object.
    • setPaymentLink

      public void setPaymentLink(String id)
    • getPaymentLinkObject

      public PaymentLink getPaymentLinkObject()
      Get expanded paymentLink.
    • setPaymentLinkObject

      public void setPaymentLinkObject(PaymentLink expandableObject)
    • getSetupIntent

      public String getSetupIntent()
      Get ID of expandable setupIntent object.
    • setSetupIntent

      public void setSetupIntent(String id)
    • getSetupIntentObject

      public SetupIntent getSetupIntentObject()
      Get expanded setupIntent.
    • setSetupIntentObject

      public void setSetupIntentObject(SetupIntent expandableObject)
    • getSubscription

      public String getSubscription()
      Get ID of expandable subscription object.
    • setSubscription

      public void setSubscription(String id)
    • getSubscriptionObject

      public Subscription getSubscriptionObject()
      Get expanded subscription.
    • setSubscriptionObject

      public void setSubscriptionObject(Subscription expandableObject)
    • create

      public static Session create(Map<String,Object> params) throws StripeException
      Creates a Session object.
      Throws:
      StripeException
    • create

      public static Session create(Map<String,Object> params, RequestOptions options) throws StripeException
      Creates a Session object.
      Throws:
      StripeException
    • create

      public static Session create(SessionCreateParams params) throws StripeException
      Creates a Session object.
      Throws:
      StripeException
    • create

      public static Session create(SessionCreateParams params, RequestOptions options) throws StripeException
      Creates a Session object.
      Throws:
      StripeException
    • expire

      public Session expire() throws StripeException
      A Session can be expired when it is in one of these statuses: open

      After it expires, a customer can’t complete a Session and customers loading the Session see a message saying the Session is expired.

      Throws:
      StripeException
    • expire

      public Session expire(RequestOptions options) throws StripeException
      A Session can be expired when it is in one of these statuses: open

      After it expires, a customer can’t complete a Session and customers loading the Session see a message saying the Session is expired.

      Throws:
      StripeException
    • expire

      public Session expire(Map<String,Object> params) throws StripeException
      A Session can be expired when it is in one of these statuses: open

      After it expires, a customer can’t complete a Session and customers loading the Session see a message saying the Session is expired.

      Throws:
      StripeException
    • expire

      public Session expire(Map<String,Object> params, RequestOptions options) throws StripeException
      A Session can be expired when it is in one of these statuses: open

      After it expires, a customer can’t complete a Session and customers loading the Session see a message saying the Session is expired.

      Throws:
      StripeException
    • expire

      public Session expire(SessionExpireParams params) throws StripeException
      A Session can be expired when it is in one of these statuses: open

      After it expires, a customer can’t complete a Session and customers loading the Session see a message saying the Session is expired.

      Throws:
      StripeException
    • expire

      public Session expire(SessionExpireParams params, RequestOptions options) throws StripeException
      A Session can be expired when it is in one of these statuses: open

      After it expires, a customer can’t complete a Session and customers loading the Session see a message saying the Session is expired.

      Throws:
      StripeException
    • list

      public static SessionCollection list(Map<String,Object> params) throws StripeException
      Returns a list of Checkout Sessions.
      Throws:
      StripeException
    • list

      public static SessionCollection list(Map<String,Object> params, RequestOptions options) throws StripeException
      Returns a list of Checkout Sessions.
      Throws:
      StripeException
    • list

      public static SessionCollection list(SessionListParams params) throws StripeException
      Returns a list of Checkout Sessions.
      Throws:
      StripeException
    • list

      public static SessionCollection list(SessionListParams params, RequestOptions options) throws StripeException
      Returns a list of Checkout Sessions.
      Throws:
      StripeException
    • listLineItems

      public LineItemCollection listLineItems() throws StripeException
      When retrieving a Checkout Session, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.
      Throws:
      StripeException
    • listLineItems

      public LineItemCollection listLineItems(Map<String,Object> params) throws StripeException
      When retrieving a Checkout Session, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.
      Throws:
      StripeException
    • listLineItems

      public LineItemCollection listLineItems(Map<String,Object> params, RequestOptions options) throws StripeException
      When retrieving a Checkout Session, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.
      Throws:
      StripeException
    • listLineItems

      public LineItemCollection listLineItems(SessionListLineItemsParams params) throws StripeException
      When retrieving a Checkout Session, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.
      Throws:
      StripeException
    • listLineItems

      public LineItemCollection listLineItems(SessionListLineItemsParams params, RequestOptions options) throws StripeException
      When retrieving a Checkout Session, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.
      Throws:
      StripeException
    • retrieve

      public static Session retrieve(String session) throws StripeException
      Retrieves a Session object.
      Throws:
      StripeException
    • retrieve

      public static Session retrieve(String session, RequestOptions options) throws StripeException
      Retrieves a Session object.
      Throws:
      StripeException
    • retrieve

      public static Session retrieve(String session, Map<String,Object> params, RequestOptions options) throws StripeException
      Retrieves a Session object.
      Throws:
      StripeException
    • retrieve

      public static Session retrieve(String session, SessionRetrieveParams params, RequestOptions options) throws StripeException
      Retrieves a Session object.
      Throws:
      StripeException
    • setResponseGetter

      public void setResponseGetter(StripeResponseGetter responseGetter)
      The amount on which tax is calculated, in cents (or local equivalent).
      Specified by:
      setResponseGetter in interface StripeActiveObject
      Overrides:
      setResponseGetter in class ApiResource
      Parameters:
      responseGetter - the StripeResponseGetter instance to use for making further requests.
    • getAfterExpiration

      public Session.AfterExpiration getAfterExpiration()
      When set, provides configuration for actions to take if this Checkout Session expires.
    • getAllowPromotionCodes

      public Boolean getAllowPromotionCodes()
      Enables user redeemable promotion codes.
    • getAmountSubtotal

      public Long getAmountSubtotal()
      Total of all items before discounts or taxes are applied.
    • getAmountTotal

      public Long getAmountTotal()
      Total of all items after discounts and taxes are applied.
    • getAutomaticTax

      public Session.AutomaticTax getAutomaticTax()
    • getBillingAddressCollection

      public String getBillingAddressCollection()
      Describes whether Checkout should collect the customer's billing address. Defaults to auto.

      One of auto, or required.

    • getCancelUrl

      public String getCancelUrl()
      If set, Checkout displays a back button and customers will be directed to this URL if they decide to cancel payment and return to your website.
    • getClientReferenceId

      public String getClientReferenceId()
      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.
    • getClientSecret

      public String getClientSecret()
      Client secret to be used when initializing Stripe.js embedded checkout.
    • getConsent

      public Session.Consent getConsent()
      Results of consent_collection for this session.
    • getConsentCollection

      public Session.ConsentCollection getConsentCollection()
      When set, provides configuration for the Checkout Session to gather active consent from customers.
    • getCreated

      public Long getCreated()
      Time at which the object was created. Measured in seconds since the Unix epoch.
    • getCurrency

      public String getCurrency()
      Three-letter ISO currency code, in lowercase. Must be a supported currency.
    • getCurrencyConversion

      public Session.CurrencyConversion getCurrencyConversion()
      Currency conversion details for automatic currency conversion sessions.
    • getCustomFields

      public List<Session.CustomField> getCustomFields()
      Collect additional information from your customer using custom fields. Up to 3 fields are supported.
    • getCustomText

      public Session.CustomText getCustomText()
    • getCustomerCreation

      public String getCustomerCreation()
      Configure whether a Checkout Session creates a Customer when the Checkout Session completes.

      One of always, or if_required.

    • getCustomerDetails

      public Session.CustomerDetails getCustomerDetails()
      The customer details including the customer's tax exempt status and the customer's tax IDs. Customer's address details are not present on Sessions in setup mode.
    • getCustomerEmail

      public String getCustomerEmail()
      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 customer attribute.
    • getExpiresAt

      public Long getExpiresAt()
      The timestamp at which the Checkout Session will expire.
    • getInvoiceCreation

      public Session.InvoiceCreation getInvoiceCreation()
      Details on the state of invoice creation for the Checkout Session.
    • getLineItems

      public LineItemCollection getLineItems()
      The line items purchased by the customer.
    • getLivemode

      public Boolean getLivemode()
      Has the value true if the object exists in live mode or the value false if the object exists in test mode.
    • getLocale

      public String getLocale()
      The IETF language tag of the locale Checkout is displayed in. If blank or auto, the browser's locale is used.

      One of auto, bg, cs, da, de, el, en, en-GB, es, es-419, et, fi, fil, fr, fr-CA, hr, hu, id, it, ja, ko, lt, lv, ms, mt, nb, nl, pl, pt, pt-BR, ro, ru, sk, sl, sv, th, tr, vi, zh, zh-HK, or zh-TW.

    • getMetadata

      public Map<String,String> getMetadata()
      Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
    • getMode

      public String getMode()
      The mode of the Checkout Session.

      One of payment, setup, or subscription.

    • getObject

      public String getObject()
      String representing the object's type. Objects of the same type share the same value.

      Equal to checkout.session.

    • getPaymentMethodCollection

      public String getPaymentMethodCollection()
      Configure whether a Checkout Session should collect a payment method. Defaults to always.

      One of always, or if_required.

    • getPaymentMethodConfigurationDetails

      public Session.PaymentMethodConfigurationDetails getPaymentMethodConfigurationDetails()
      Information about the payment method configuration used for this Checkout session if using dynamic payment methods.
    • getPaymentMethodOptions

      public Session.PaymentMethodOptions getPaymentMethodOptions()
      Payment-method-specific configuration for the PaymentIntent or SetupIntent of this CheckoutSession.
    • getPaymentMethodTypes

      public List<String> getPaymentMethodTypes()
      A list of the types of payment methods (e.g. card) this Checkout Session is allowed to accept.
    • getPaymentStatus

      public String getPaymentStatus()
      The payment status of the Checkout Session, one of paid, unpaid, or no_payment_required. You can use this value to decide when to fulfill your customer's order.
    • getPhoneNumberCollection

      public Session.PhoneNumberCollection getPhoneNumberCollection()
    • getRecoveredFrom

      public String getRecoveredFrom()
      The ID of the original expired Checkout Session that triggered the recovery flow.
    • getRedirectOnCompletion

      public String getRedirectOnCompletion()
      This parameter applies to ui_mode: embedded. Learn more about the redirect behavior of embedded sessions. Defaults to always.

      One of always, if_required, or never.

    • getReturnUrl

      public String getReturnUrl()
      Applies to Checkout Sessions with ui_mode: embedded. The URL to redirect your customer back to after they authenticate or cancel their payment on the payment method's app or site.
    • getSavedPaymentMethodOptions

      public Session.SavedPaymentMethodOptions getSavedPaymentMethodOptions()
      Controls saved payment method settings for the session. Only available in payment and subscription mode.
    • getShippingAddressCollection

      public Session.ShippingAddressCollection getShippingAddressCollection()
      When set, provides configuration for Checkout to collect a shipping address from a customer.
    • getShippingCost

      public Session.ShippingCost getShippingCost()
      The details of the customer cost of shipping, including the customer chosen ShippingRate.
    • getShippingDetails

      public ShippingDetails getShippingDetails()
      Shipping information for this Checkout Session.
    • getShippingOptions

      public List<Session.ShippingOption> getShippingOptions()
      The shipping rate options applied to this Session.
    • getStatus

      public String getStatus()
      The status of the Checkout Session, one of open, complete, or expired.
    • getSubmitType

      public String getSubmitType()
      Describes the type of transaction being performed by Checkout in order to customize relevant text on the page, such as the submit button. submit_type can only be specified on Checkout Sessions in payment mode. If blank or auto, pay is used.

      One of auto, book, donate, or pay.

    • getSuccessUrl

      public String getSuccessUrl()
      The URL the customer will be directed to after the payment or subscription creation is successful.
    • getTaxIdCollection

      public Session.TaxIdCollection getTaxIdCollection()
    • getTotalDetails

      public Session.TotalDetails getTotalDetails()
      Tax and discount details for the computed total amount.
    • getUiMode

      public String getUiMode()
      The UI mode of the Session. Defaults to hosted.

      One of embedded, or hosted.

    • getUrl

      public String getUrl()
      The URL to the Checkout Session. Redirect customers to this URL to take them to Checkout. If you’re using Custom Domains, the URL will use your subdomain. Otherwise, it’ll use checkout.stripe.com. This value is only present when the session is active.
    • setAfterExpiration

      public void setAfterExpiration(Session.AfterExpiration afterExpiration)
      When set, provides configuration for actions to take if this Checkout Session expires.
    • setAllowPromotionCodes

      public void setAllowPromotionCodes(Boolean allowPromotionCodes)
      Enables user redeemable promotion codes.
    • setAmountSubtotal

      public void setAmountSubtotal(Long amountSubtotal)
      Total of all items before discounts or taxes are applied.
    • setAmountTotal

      public void setAmountTotal(Long amountTotal)
      Total of all items after discounts and taxes are applied.
    • setAutomaticTax

      public void setAutomaticTax(Session.AutomaticTax automaticTax)
    • setBillingAddressCollection

      public void setBillingAddressCollection(String billingAddressCollection)
      Describes whether Checkout should collect the customer's billing address. Defaults to auto.

      One of auto, or required.

    • setCancelUrl

      public void setCancelUrl(String cancelUrl)
      If set, Checkout displays a back button and customers will be directed to this URL if they decide to cancel payment and return to your website.
    • setClientReferenceId

      public void setClientReferenceId(String clientReferenceId)
      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.
    • setClientSecret

      public void setClientSecret(String clientSecret)
      Client secret to be used when initializing Stripe.js embedded checkout.
    • setConsent

      public void setConsent(Session.Consent consent)
      Results of consent_collection for this session.
    • setConsentCollection

      public void setConsentCollection(Session.ConsentCollection consentCollection)
      When set, provides configuration for the Checkout Session to gather active consent from customers.
    • setCreated

      public void setCreated(Long created)
      Time at which the object was created. Measured in seconds since the Unix epoch.
    • setCurrency

      public void setCurrency(String currency)
      Three-letter ISO currency code, in lowercase. Must be a supported currency.
    • setCurrencyConversion

      public void setCurrencyConversion(Session.CurrencyConversion currencyConversion)
      Currency conversion details for automatic currency conversion sessions.
    • setCustomFields

      public void setCustomFields(List<Session.CustomField> customFields)
      Collect additional information from your customer using custom fields. Up to 3 fields are supported.
    • setCustomText

      public void setCustomText(Session.CustomText customText)
    • setCustomerCreation

      public void setCustomerCreation(String customerCreation)
      Configure whether a Checkout Session creates a Customer when the Checkout Session completes.

      One of always, or if_required.

    • setCustomerDetails

      public void setCustomerDetails(Session.CustomerDetails customerDetails)
      The customer details including the customer's tax exempt status and the customer's tax IDs. Customer's address details are not present on Sessions in setup mode.
    • setCustomerEmail

      public void setCustomerEmail(String customerEmail)
      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 customer attribute.
    • setExpiresAt

      public void setExpiresAt(Long expiresAt)
      The timestamp at which the Checkout Session will expire.
    • setId

      public void setId(String id)
      Unique identifier for the object.
    • setInvoiceCreation

      public void setInvoiceCreation(Session.InvoiceCreation invoiceCreation)
      Details on the state of invoice creation for the Checkout Session.
    • setLineItems

      public void setLineItems(LineItemCollection lineItems)
      The line items purchased by the customer.
    • setLivemode

      public void setLivemode(Boolean livemode)
      Has the value true if the object exists in live mode or the value false if the object exists in test mode.
    • setLocale

      public void setLocale(String locale)
      The IETF language tag of the locale Checkout is displayed in. If blank or auto, the browser's locale is used.

      One of auto, bg, cs, da, de, el, en, en-GB, es, es-419, et, fi, fil, fr, fr-CA, hr, hu, id, it, ja, ko, lt, lv, ms, mt, nb, nl, pl, pt, pt-BR, ro, ru, sk, sl, sv, th, tr, vi, zh, zh-HK, or zh-TW.

    • setMetadata

      public void setMetadata(Map<String,String> metadata)
      Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
    • setMode

      public void setMode(String mode)
      The mode of the Checkout Session.

      One of payment, setup, or subscription.

    • setObject

      public void setObject(String object)
      String representing the object's type. Objects of the same type share the same value.

      Equal to checkout.session.

    • setPaymentMethodCollection

      public void setPaymentMethodCollection(String paymentMethodCollection)
      Configure whether a Checkout Session should collect a payment method. Defaults to always.

      One of always, or if_required.

    • setPaymentMethodConfigurationDetails

      public void setPaymentMethodConfigurationDetails(Session.PaymentMethodConfigurationDetails paymentMethodConfigurationDetails)
      Information about the payment method configuration used for this Checkout session if using dynamic payment methods.
    • setPaymentMethodOptions

      public void setPaymentMethodOptions(Session.PaymentMethodOptions paymentMethodOptions)
      Payment-method-specific configuration for the PaymentIntent or SetupIntent of this CheckoutSession.
    • setPaymentMethodTypes

      public void setPaymentMethodTypes(List<String> paymentMethodTypes)
      A list of the types of payment methods (e.g. card) this Checkout Session is allowed to accept.
    • setPaymentStatus

      public void setPaymentStatus(String paymentStatus)
      The payment status of the Checkout Session, one of paid, unpaid, or no_payment_required. You can use this value to decide when to fulfill your customer's order.
    • setPhoneNumberCollection

      public void setPhoneNumberCollection(Session.PhoneNumberCollection phoneNumberCollection)
    • setRecoveredFrom

      public void setRecoveredFrom(String recoveredFrom)
      The ID of the original expired Checkout Session that triggered the recovery flow.
    • setRedirectOnCompletion

      public void setRedirectOnCompletion(String redirectOnCompletion)
      This parameter applies to ui_mode: embedded. Learn more about the redirect behavior of embedded sessions. Defaults to always.

      One of always, if_required, or never.

    • setReturnUrl

      public void setReturnUrl(String returnUrl)
      Applies to Checkout Sessions with ui_mode: embedded. The URL to redirect your customer back to after they authenticate or cancel their payment on the payment method's app or site.
    • setSavedPaymentMethodOptions

      public void setSavedPaymentMethodOptions(Session.SavedPaymentMethodOptions savedPaymentMethodOptions)
      Controls saved payment method settings for the session. Only available in payment and subscription mode.
    • setShippingAddressCollection

      public void setShippingAddressCollection(Session.ShippingAddressCollection shippingAddressCollection)
      When set, provides configuration for Checkout to collect a shipping address from a customer.
    • setShippingCost

      public void setShippingCost(Session.ShippingCost shippingCost)
      The details of the customer cost of shipping, including the customer chosen ShippingRate.
    • setShippingDetails

      public void setShippingDetails(ShippingDetails shippingDetails)
      Shipping information for this Checkout Session.
    • setShippingOptions

      public void setShippingOptions(List<Session.ShippingOption> shippingOptions)
      The shipping rate options applied to this Session.
    • setStatus

      public void setStatus(String status)
      The status of the Checkout Session, one of open, complete, or expired.
    • setSubmitType

      public void setSubmitType(String submitType)
      Describes the type of transaction being performed by Checkout in order to customize relevant text on the page, such as the submit button. submit_type can only be specified on Checkout Sessions in payment mode. If blank or auto, pay is used.

      One of auto, book, donate, or pay.

    • setSuccessUrl

      public void setSuccessUrl(String successUrl)
      The URL the customer will be directed to after the payment or subscription creation is successful.
    • setTaxIdCollection

      public void setTaxIdCollection(Session.TaxIdCollection taxIdCollection)
    • setTotalDetails

      public void setTotalDetails(Session.TotalDetails totalDetails)
      Tax and discount details for the computed total amount.
    • setUiMode

      public void setUiMode(String uiMode)
      The UI mode of the Session. Defaults to hosted.

      One of embedded, or hosted.

    • setUrl

      public void setUrl(String url)
      The URL to the Checkout Session. Redirect customers to this URL to take them to Checkout. If you’re using Custom Domains, the URL will use your subdomain. Otherwise, it’ll use checkout.stripe.com. This value is only present when the session is active.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getId

      public String getId()
      Unique identifier for the object.
      Specified by:
      getId in interface HasId