Checkout sessions

Checkout sessions represent your customer’s journey through the purchase flow when using Checkout. Your integration should create a new checkout session each time a customer begins the purchase process.

The CheckoutSession object

Name
object
Type
"checkout_session",
Description
Literal representing the object’s type.
Name
id
Type
string,
Description
Unique identifier for the object.
Name
live
Type
boolean,
Description
Has the value true if the object exists in a production environment or the value false if the object exists in a sandbox environment.
Name
created_at
Type
integer,
Description
Time at which the object was created. Measured in milliseconds since the Unix epoch.
Name
amount
Type
integer,
Description
The total of the checkout session in cents.
Name
amount_collected
Type
integer,
Description
The amount collected from the customer in successful payments.
Name
client_secret
Type
string,
Description
The client secret for the checkout session. Return this value to the client-side Checkout SDK to initialize it.
Name
customer
Type
string or Customer or null,
Description
Expandable. The customer associated with the checkout session.
Name
customer_details
Type
object,
Description
The customer’s details entered in this session. When the session completes, the created customer will inherit these values.
Properties
Name
invoice
Type
string or object or null,
Description
Expandable. The invoice this checkout session was created from.
Properties
Name
line_items
Type
array of object or null,
Description
The line items representing the products or services being purchased.
Properties
Name
metadata
Type
object,
Description
A key-value store that is attached to the object. Useful for storing miscellaneous structured data for your integration’s internal use.
Name
mode
Type
enum,
Description
The mode of the session determines if payment methods are saved and when the customer is charged.
Name
payments
Type
array of Payments or null or null,
Description
Expandable. The payments associated with the checkout session.
Name
status
Type
enum,
Description
The status of the session.
Name
submit_label
Type
enum,
Description
Specify the submit intent for the session. Used to adjust the text on Checkout components to reflect the type of purchase.

The CheckoutSession object

{
  "object": "checkout_session",
  "id": "cs_MyJuJvswjRM54vPXr6qBh2",
  "live": false,
  "created_at": 1750000000000,
  "amount": 1000,
  "amount_collected": 1000,
  "client_secret": "uEyLI6rmFylTwIBik5cpn8ge",
  "customer": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
  "customer_details": {
    "email": null,
    "name": null,
    "phone": null
  },
  "payments": [],
  "invoice": null,
  "line_items": [],
  "metadata": {},
  "mode": "payment",
  "status": "complete",
  "submit_label": "auto"
}

Get a checkout session

Retrieve a checkout session by its ID.

Optional parameters

Name
expand
Type
object,
Description
Optional object that allows you to expand certain ID fields to include related resources.
Properties

Returns

Returns the checkout session object.

Retrieve a checkout session

const session = await bias.checkout.sessions.get("id");

Response example

{
  "object": "checkout_session",
  "id": "cs_MyJuJvswjRM54vPXr6qBh2",
  "live": false,
  "created_at": 1750000000000,
  "amount": 1000,
  "amount_collected": 1000,
  "client_secret": "uEyLI6rmFylTwIBik5cpn8ge",
  "customer": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
  "customer_details": {
    "email": null,
    "name": null,
    "phone": null
  },
  "payments": [],
  "invoice": null,
  "line_items": [],
  "metadata": {},
  "mode": "payment",
  "status": "complete",
  "submit_label": "auto"
}

List all checkout sessions

Retrieve a paginated list of checkout sessions.

Optional parameters

Name
expand
Type
object,
Description
Optional object that allows you to expand certain ID fields to include related resources.
Properties
Name
ending_before
Type
string,
Description
A cursor for use in pagination. ending_before is an object ID that results will end before. Used to move backward through the list.
Name
starting_after
Type
string,
Description
A cursor for use in pagination. starting_after is an object ID that results will start after. Used to move forward through the list.
Name
limit
Type
number, at least 1, at most 1000, default is 50
Description
Maximum number of objects to return.
Name
filters
Type
object, object, or object,
Description
Filters to apply to the list. Combine multiple conditions with and and or.
Properties

Returns

Returns a list of checkout session objects.

List all checkout sessions

const session = await bias.checkout.sessions.list();

Response example

{
  "object": "list",
  "items": {
    "object": "checkout_session",
    "id": "cs_MyJuJvswjRM54vPXr6qBh2",
    "live": false,
    "created_at": 1750000000000,
    "amount": 1000,
    "amount_collected": 1000,
    "client_secret": "uEyLI6rmFylTwIBik5cpn8ge",
    "customer": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
    "customer_details": {
      "email": null,
      "name": null,
      "phone": null
    },
    "payments": [],
    "invoice": null,
    "line_items": [],
    "metadata": {},
    "mode": "payment",
    "status": "complete",
    "submit_label": "auto"
  },
  "has_more": false
}

Create a checkout session

Create a new checkout session in response to a customer purchase intent. Return client_secret to the browser for use with the Checkout SDK.

Optional parameters

Name
amount
Type
integer or null,
Description
Amount in cents for this session. Mutually exclusive with line_items and invoice.
Name
line_items
Type
array of objects or null,
Description
The line items representing the products or services being purchased.
Properties
Name
customer
Type
string,
Description
Expandable. The customer associated with the checkout session.
Name
customer_details
Type
object,
Description
The customer’s details entered in this session. When the session completes, the created customer will inherit these values.
Properties
Name
invoice
Type
string,
Description
Expandable. The invoice this checkout session was created from.
Name
metadata
Type
object or null,
Description
A key-value store that is attached to the object. Useful for storing miscellaneous structured data for your integration’s internal use.
Name
mode
Type
enum, default is payment
Description
The mode of the session determines if payment methods are saved and when the customer is charged.
Name
submit_label
Type
enum, default is auto
Description
Specify the submit intent for the session. Used to adjust the text on Checkout components to reflect the type of purchase.

Returns

Returns the checkout session object.

Create a checkout session

const session = await bias.checkout.sessions.create({
  customer: "cus_aB4DEXqbFGOlpEOxwp0Fx1",
  line_items: [
    {
      price: "price_dz1NVvl5CSogERkeA9Ng67",
      quantity: 2
    }
  ]
});

Response example

{
  "object": "checkout_session",
  "id": "cs_MyJuJvswjRM54vPXr6qBh2",
  "live": false,
  "created_at": 1750000000000,
  "amount": 1000,
  "amount_collected": 1000,
  "client_secret": "uEyLI6rmFylTwIBik5cpn8ge",
  "customer": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
  "customer_details": {
    "email": null,
    "name": null,
    "phone": null
  },
  "payments": [],
  "invoice": null,
  "line_items": [],
  "metadata": {},
  "mode": "payment",
  "status": "complete",
  "submit_label": "auto"
}

Expire a checkout session

Expire a checkout session, invalidating it and preventing further payments from being created with it.

Returns

Returns the checkout session object.

Expire a checkout session

const session = await bias.checkout.sessions.expire("id");

Response example

{
  "object": "checkout_session",
  "id": "cs_MyJuJvswjRM54vPXr6qBh2",
  "live": false,
  "created_at": 1750000000000,
  "amount": 1000,
  "amount_collected": 1000,
  "client_secret": "uEyLI6rmFylTwIBik5cpn8ge",
  "customer": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
  "customer_details": {
    "email": null,
    "name": null,
    "phone": null
  },
  "payments": [],
  "invoice": null,
  "line_items": [],
  "metadata": {},
  "mode": "payment",
  "status": "complete",
  "submit_label": "auto"
}

Update a checkout session

Update the properties of a requires_confirmation checkout session. Only the metadata can be updated on checkout sessions that have already been confirmed.

Optional parameters

Name
line_items
Type
array of object or object,
Description
The line items representing what is being purchased
Properties
Name
customer
Type
string,
Description
The customer's associated with the session.
Name
customer_details
Type
object,
Description
The customer’s details entered in this session. When the session completes, the created customer will inherit these values.
Properties
Name
metadata
Type
object or null,
Description
A key-value store that is attached to the object. Useful for storing miscellaneous structured data for your integration’s internal use.

Returns

Returns the checkout session object.

Update a checkout session

const session = await bias.checkout.sessions.update("id", {
  line_items: [
    {
      id: "li_rbw8iroSXBkFMZ8bisSxK",
      quantity: 3
    },
    {
      price: "price_dz1NVvl5CSogERkeA9Ng67",
      quantity: 1
    }
  ],
  customer: "cus_aB4DEXqbFGOlpEOxwp0Fx1"
});

Response example

{
  "object": "checkout_session",
  "id": "cs_MyJuJvswjRM54vPXr6qBh2",
  "live": false,
  "created_at": 1750000000000,
  "amount": 1000,
  "amount_collected": 1000,
  "client_secret": "uEyLI6rmFylTwIBik5cpn8ge",
  "customer": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
  "customer_details": {
    "email": null,
    "name": null,
    "phone": null
  },
  "payments": [],
  "invoice": null,
  "line_items": [],
  "metadata": {},
  "mode": "payment",
  "status": "complete",
  "submit_label": "auto"
}