The Customer Session object 

Attributes

  • client_secretstring

    The client secret of this Customer Session. Used on the client to set up secure access to the given customer.

    The client secret can be used to provide access to customer from your frontend. It should not be stored, logged, or exposed to anyone other than the relevant customer. Make sure that you have TLS enabled on any page that includes the client secret.

  • componentsobject

    This hash defines which component is enabled and the features it supports.

  • customerstringExpandable

    The Customer the Customer Session was created for.

  • expires_attimestamp

    The timestamp at which this Customer Session will expire.

More attributes

  • objectstring

  • createdtimestamp

  • livemodeboolean

The 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
}

Create a Customer Session 

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.

  • customerstringRequired

    The ID of an existing customer for which to create the Customer Session.

Returns

Returns a Customer Session object.

POST /v1/customer_sessions
curl https://api.stripe.com/v1/customer_sessions \
-u "sk_test_BQokikJ...2HlWgH4olfQ2sk_test_BQokikJOvBiI2HlWgH4olfQ2:" \
-d customer=cus_PO34b57IOUb83c \
-d "components[pricing_table][enabled]"=true
Response
{
"object": "customer_session",
"client_secret": "_POpxYpmkXdtttYtZQYhrsOJZ2RCQ9kCqqXRU6qrP5c4Jgje",
"components": {
"buy_button": {
"enabled": false
},
"pricing_table": {
"enabled": true
}
},
"customer": "cus_PO34b57IOUb83c",
"expires_at": 1684790027,
"livemode": false
}

Disputes 

A dispute occurs when a customer questions your charge with their card issuer. When this happens, you have the opportunity to respond to the dispute with evidence that shows that the charge is legitimate.

Related guide: Disputes and fraud

Events 

Snapshot events allow you to track and react to activity in your Stripe integration. When the state of another API resource changes, Stripe creates an Event object that contains all the relevant information associated with that action, including the affected API resource. For example, a successful payment triggers a charge.succeeded event, which contains the Charge in the event’s data property. Some actions trigger multiple events. For example, if you create a new subscription for a customer, it triggers both a customer.subscription.created event and a charge.succeeded event.

Configure an event destination in your account to listen for events that represent actions your integration needs to respond to. Additionally, you can retrieve an individual event or a list of events from the API.

Connect platforms can also receive event notifications that occur in their connected accounts. These events include an account attribute that identifies the relevant connected account.

You can access events through the Retrieve Event API for 30 days.

Events v2

Events are generated to keep you informed of activity in your business account. APIs in the /v2 namespace generate thin events which have small, unversioned payloads that include a reference to the ID of the object that has changed. The Events v2 API returns these new thin events. Retrieve the event object for additional data about the event. Use the related object ID in the event payload to fetch the API resource of the object associated with the event. Comparatively, events generated by most API v1 include a versioned snapshot of an API object in their payload.