Creates a Customer Session object that includes a single-use client secret that you can use on your front-end to grant client-side API access for certain customer resources.
Parameters
- componentsobjectRequired
Configuration for each component. Exactly 1 component must be enabled.
- components.
object Configuration for buy button.
- components.
buy_button. booleanRequired Whether the buy button is enabled.
- components.
payment_ elementobject Configuration for the Payment Element.
- components.
payment_element. enabledbooleanRequired Whether the Payment Element is enabled.
- components.
payment_element. featuresobject This hash defines whether the Payment Element supports certain features.
- components.
payment_element. features. payment_ method_ allow_ redisplay_ filtersarray of enums A list of
allow_
values that controls which saved payment methods the Payment Element displays by filtering to only show payment methods with anredisplay allow_
value that is present in this list.redisplay If not specified, defaults to [“always”]. In order to display all saved payment methods, specify [“always”, “limited”, “unspecified”].
Possible enum valuesalways
Use
always
to indicate that this payment method can always be shown to a customer in a checkout flow.limited
Use
limited
to indicate that this payment method can’t always be shown to a customer in a checkout flow. For example, it can only be shown in the context of a specific subscription.unspecified
This is the default value for payment methods where
allow_
wasn’t set.redisplay - components.
payment_element. features. payment_ method_ redisplayenum Controls whether or not the Payment Element shows saved payment methods. This parameter defaults to
disabled
.Possible enum valuesdisabled
The feature is disabled.
enabled
The feature is enabled.
- components.
payment_element. features. payment_ method_ redisplay_ limitinteger Determines the max number of saved payment methods for the Payment Element to display. This parameter defaults to
3
. The maximum redisplay limit is10
. - components.
payment_element. features. payment_ method_ removeenum Controls whether the Payment Element displays the option to remove a saved payment method. This parameter defaults to
disabled
.Allowing buyers to remove their saved payment methods impacts subscriptions that depend on that payment method. Removing the payment method detaches the
customer
object from that PaymentMethod.Possible enum valuesdisabled
The feature is disabled.
enabled
The feature is enabled.
- components.
payment_element. features. payment_ method_ saveenum Controls whether the Payment Element displays a checkbox offering to save a new payment method. This parameter defaults to
disabled
.If a customer checks the box, the
allow_
value on the PaymentMethod is set toredisplay 'always'
at confirmation time. For PaymentIntents, thesetup_
value is also set to the value defined infuture_ usage payment_
.method_ save_ usage Possible enum valuesdisabled
The feature is disabled.
enabled
The feature is enabled.
- components.
payment_element. features. payment_ method_ save_ usageenumRequired if payment_method_save=enabled When using PaymentIntents and the customer checks the save checkbox, this field determines the
setup_
value used to confirm the PaymentIntent.future_ usage When using SetupIntents, directly configure the
usage
value on SetupIntent creation.Possible enum valuesoff_
session Use
off_
if your customer may or may not be present in your checkout flow.session on_
session Use
on_
if you intend to only reuse the payment method when your customer is present in your checkout flow.session
- components.
pricing_ tableobject Configuration for the pricing table.
- components.
pricing_table. enabledbooleanRequired Whether the pricing table is enabled.
- customerstringRequired
The ID of an existing customer for which to create the Customer Session.
Returns
Returns a Customer Session object.
{ "object": "customer_session", "client_secret": "_POpxYpmkXdtttYtZQYhrsOJZ2RCQ9kCqqXRU6qrP5c4Jgje", "components": { "buy_button": { "enabled": false }, "pricing_table": { "enabled": true } }, "customer": "cus_PO34b57IOUb83c", "expires_at": 1684790027, "livemode": false}