Checkout sessions
A checkout session is one customer’s purchase, made in Bias Checkout at its url or in your own page with Checkout elements. Its mode sets whether it collects a payment, starts a subscription or saves a payment method. Checkout links create a session for each customer from one reusable link.
The CheckoutSession object
- Name
object
- Type
- "checkout_session",
- Description
- The object's type.
- Name
id
- Type
- string,
- Description
- Unique identifier for the object.
- Name
live
- Type
- boolean,
- Description
trueif the object is live, orfalseif it's in a sandbox.
- Name
created_at
- Type
- integer,
- Description
- When the object was created, in milliseconds since the Unix epoch.
- Name
allow_discount_codes
- Type
- boolean,
- Description
- Whether the customer can enter discount codes.
- Name
amount_collected
- Type
- integer,
- Description
- The amount the session's successful payments collected, in cents.
- Name
amount_remaining
- Type
- integer, at least 0,
- Description
- The amount left to pay in cents, after payments that succeeded or are processing.
0once the session isn'topen. With dual pricing, card payments chargedual_pricing.amount_remaininginstead.
- Name
billing_details
- Type
- object or null,
- Description
- The billing name and address.
- Properties
- Name
billing_details_collection
- Type
- object or null,
- Description
- Which billing details checkout collects, or
nullwhen it doesn't collect any. - Properties
- Name
client_details
- Type
- object or null,
- Description
- The customer's browser, recorded when they open the session.
- Properties
- Name
client_secret
- Type
- string,
- Description
- The secret that loads the session in Checkout elements.
- Name
company_mandate_text
- Type
- string or null,
- Description
- The
mandate_textfor a company bank account (account_holder_type: company).
- Name
customer
- Type
- string or Customer or null,
- Description
- Expandable. The session's customer. Without one, Bias creates a customer from
customer_detailswhen the session completes.
- Name
customer_details
- Type
- object,
- Description
- The customer's contact details.
- Properties
- Name
discounts
- Type
- array of AppliedDiscounts or null,
- Description
- Expandable. Discounts on the whole session.
- Name
dual_pricing
- Type
- object or null,
- Description
- Dual pricing on a one-off invoice's session that accepts bank payments. Card payments pay
totalplusrate, and bank payments paytotal. - Properties
- Name
invoice
- Type
- string or Invoice or null,
- Description
- Expandable. The invoice the session pays.
- Name
line_items
- Type
- array of LineItems or null,
- Description
- Expandable. What the customer is buying.
- Name
mandate_text
- Type
- string or null,
- Description
- The ACH debit authorization the customer accepts when the session saves a personal bank account for later payments, recorded on the account's mandate.
nullwhen the session doesn't save bank accounts.
- Name
metadata
- Type
- object,
- Description
- Your own key-value data on the object.
- Name
mode
- Type
- enum,
- Description
- What the session collects.
- Properties
- Name
payment_method_types
- Type
- array of enums,
- Description
- The payment method types the customer can pay with.
- Properties
- Name
payments
- Type
- array of Payments or null or null,
- Description
- Expandable. The session's payments.
- Name
phone_number_collection
- Type
- boolean,
- Description
- Whether checkout collects the customer's phone number. Sessions that collect a shipping address ask for it there and save it as the shipping phone too.
- Name
shipping_address_collection
- Type
- object or null,
- Description
- Where checkout collects a shipping address, or
nullwhen it doesn't collect one. - Properties
- Name
shipping_cost
- Type
- object or null,
- Description
- The selected shipping option.
- Properties
- Name
shipping_details
- Type
- object or null,
- Description
- The name, phone and address the order ships to.
- Properties
- Name
shipping_options
- Type
- array of objects,
- Description
- The shipping options the customer can choose from.
- Properties
- Name
status
- Type
- enum,
- Description
- The session's status.
- Properties
- Name
submit_label
- Type
- enum,
- Description
- The payment button's label.
- Properties
- Name
subscription
- Type
- string or null,
- Description
- In
subscriptionmode, the subscription the session created. Insetupmode, the subscription whose payment method it replaces.
- Name
subscription_data
- Type
- object or null,
- Description
- Settings for the subscription a
subscriptionmode session creates. - Properties
- Name
subscription_terms
- Type
- string or null,
- Description
- The renewal terms the customer agrees to by paying, shown under the payment button.
- Name
subtotal
- Type
- integer, at least 0,
- Description
- The line items' amount after discounts, before shipping and tax, in cents.
- Name
success_url
- Type
- string or null,
- Description
- Where Bias Checkout sends the customer after the session completes.
- Name
tax_total
- Type
- integer, at least 0,
- Description
- The tax in
total, in cents.
- Name
total
- Type
- integer, at least 0,
- Description
- The total in cents, including shipping and tax. For an invoice's session, it's what the invoice has left to pay.
- Name
updated_at
- Type
- integer,
- Description
- When the object was last updated, in milliseconds since the Unix epoch.
- Name
url
- Type
- string,
- Description
- The session's Bias Checkout page.
The CheckoutSession object
Get a checkout session
Retrieve a checkout session by its ID.
Required parameters
- Name
id
- Type
- string,
- Description
- The ID of the checkout session to retrieve.
Optional parameters
- Name
expand
- Type
- object,
- Description
- Related objects to expand in the response.
- Properties
Returns
Returns the checkout session object.
Retrieve a checkout session
Response example
List all checkout sessions
Retrieve a paginated list of checkout sessions.
Optional parameters
- Name
expand
- Type
- object,
- Description
- Related objects to expand in the response.
- Properties
- Name
ending_before
- Type
- string,
- Description
- The ID of the object to list before, for pagination.
- Name
starting_after
- Type
- string,
- Description
- The ID of the object to list after, for pagination.
- Name
limit
- Type
- integer, at least 1, at most 1000, default is 50
- Description
- The maximum number of objects to return, from 1 to 1000. Defaults to 50.
- Name
filters
- Type
- object, object, or object,
- Description
- Properties
Returns
Returns a list of checkout session objects.
List all checkout sessions
Response example
Create a checkout session
Create a session on your server for each purchase. Redirect the customer to its url for Bias Checkout, or pass its client_secret to Checkout elements in the browser.
Optional parameters
- Name
expand
- Type
- object,
- Properties
- Name
allow_discount_codes
- Type
- boolean, default is false
- Description
- Whether the customer can enter discount codes. Not allowed with
invoice.
- Name
line_items
- Type
- array of objects or null,
- Description
- What the customer is buying.
- Properties
- Name
discounts
- Type
- array of object,
- Description
- Discounts or discount codes for the whole session. Not allowed with
invoice. - Properties
- Name
customer
- Type
- string,
- Description
- The session's customer. Without one, Bias creates a customer from
customer_detailswhen the session completes.
- Name
customer_details
- Type
- object,
- Description
- The customer's contact details.
- Properties
- Name
shipping_details
- Type
- object or null,
- Description
- The name, phone and address the order ships to.
- Properties
- Name
shipping_address_collection
- Type
- boolean or object or null,
- Description
- Where checkout collects a shipping address.
trueallows every supported country, andfalseornullturns collection off. - Properties
- Name
billing_details_collection
- Type
- boolean or object or null,
- Description
- Which billing details checkout collects.
truecollects the name and full address, andfalseornullturns collection off. - Properties
- Name
phone_number_collection
- Type
- boolean,
- Description
- Whether checkout collects the customer's phone number. Sessions that collect a shipping address ask for it there and save it as the shipping phone too.
- Name
shipping_options
- Type
- array of string or object or null,
- Description
- The shipping options the customer can choose from, as shipping rate IDs or new shipping rates. The first one is selected.
- Properties
- Name
invoice
- Type
- string,
- Description
- The invoice the session pays.
- Name
dual_pricing
- Type
- object or null,
- Description
- Dual pricing on a one-off invoice's session that accepts bank payments. Card payments pay
totalplusrate, and bank payments paytotal. Defaults to the rate in your invoice settings, andnullturns it off. - Properties
- Name
metadata
- Type
- object or null,
- Description
- Your own key-value data on the object.
- Name
mode
- Type
- enum,
- Description
- What the session collects.
- Properties
- Name
payment_method_types
- Type
- array of enums,
- Description
- The payment method types the customer can pay with. Defaults to the ones enabled in your settings.
- Properties
- Name
submit_label
- Type
- enum,
- Description
- The payment button's label.
- Properties
- Name
success_url
- Type
- string or null,
- Description
- Where Bias Checkout sends the customer after the session completes.
- Name
subscription_data
- Type
- object,
- Description
- Settings for the subscription a
subscriptionmode session creates. - Properties
- Name
subscription
- Type
- string,
- Description
- In
setupmode, a subscription whose payment method the saved one replaces. The session's customer defaults to the subscription's, and an unpaid invoice is charged to the new payment method.
Returns
Returns the checkout session object.
Create a checkout session
Response example
Expire a checkout session
Expiring an open session stops the customer from paying it.
Required parameters
- Name
id
- Type
- string,
Returns
Returns the checkout session object.
Expire a checkout session
Response example
Update a checkout session
Updates change an open session’s line items, discounts, customer or shipping before the customer pays.
Required parameters
- Name
id
- Type
- string,
- Description
- The ID of the checkout session to update.
Optional parameters
- Name
expand
- Type
- object,
- Properties
- Name
allow_discount_codes
- Type
- boolean,
- Description
- Whether the customer can enter discount codes.
- Name
line_items
- Type
- array of objects,
- Description
- What the customer is buying, replacing the current line items. Include an existing line item's
idto keep or change it. - Properties
- Name
discounts
- Type
- array of object or object,
- Description
- Discounts or discount codes for the whole session, replacing the current ones.
- Properties
- Name
customer
- Type
- string,
- Description
- The session's customer.
- Name
customer_details
- Type
- object,
- Description
- The customer's contact details.
- Properties
- Name
shipping_details
- Type
- object or null,
- Description
- The name, phone and address the order ships to.
- Properties
- Name
shipping_address_collection
- Type
- boolean or object or null,
- Description
- Where checkout collects a shipping address.
trueallows every supported country, andfalseornullturns collection off. - Properties
- Name
billing_details_collection
- Type
- boolean or object or null,
- Description
- Which billing details checkout collects.
truecollects the name and full address, andfalseornullturns collection off. - Properties
- Name
phone_number_collection
- Type
- boolean,
- Description
- Whether checkout collects the customer's phone number. Sessions that collect a shipping address ask for it there and save it as the shipping phone too.
- Name
billing_details
- Type
- object or null,
- Description
- The billing name and address.
- Properties
- Name
shipping_options
- Type
- array of string or object or null,
- Description
- The shipping options the customer can choose from, replacing the current ones. The first one is selected.
- Properties
- Name
shipping_rate
- Type
- string or null,
- Description
- The shipping rate of the option the customer chose, or
nullto clear the choice.
- Name
dual_pricing
- Type
- object or null,
- Description
- Dual pricing on a one-off invoice's session that accepts bank payments. Card payments pay
totalplusrate, and bank payments paytotal. - Properties
- Name
metadata
- Type
- object or null,
- Description
- Your own key-value data on the object.
Returns
Returns the checkout session object.
Update a checkout session
Response example
Apply a discount code
Applying a code takes a customer’s discount off an open session. A session can have several codes, each for a different discount.
In the browser, with the session’s client secret, current stands in for the session ID, and the session needs allow_discount_codes: true.
Required parameters
- Name
id
- Type
- string,
- Name
code
- Type
- string,
- Description
- The discount code to apply.
Optional parameters
- Name
expand
- Type
- object,
- Properties
Returns
Returns the updated checkout session object.
Apply a discount code
Response example
Remove a discount code
Removing a code takes its discount off the session. Pass the applied discount ID from the session’s discounts.
Required parameters
- Name
id
- Type
- string,
- Name
discount
- Type
- string,
- Description
- The ID of the applied discount to remove.
Optional parameters
- Name
expand
- Type
- object,
- Properties
Returns
Returns the updated checkout session object.