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
true if the object is live, or false if 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. 0 once the session isn't open. With dual pricing, card payments charge dual_pricing.amount_remaining instead.
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 null when 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_text for 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_details when 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 total plus rate, and bank payments pay total.
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. null when 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 null when 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 subscription mode, the subscription the session created. In setup mode, the subscription whose payment method it replaces.
Name
subscription_data
Type
object or null,
Description
Settings for the subscription a subscription mode 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

{
  "object": "checkout_session",
  "id": "cs_MyJuJvswjRM54vPXr6qBh2",
  "live": false,
  "created_at": 1750000000000,
  "updated_at": 1750000000000,
  "total": 2300,
  "subtotal": 1800,
  "amount_collected": 2300,
  "amount_remaining": 0,
  "tax_total": 0,
  "allow_discount_codes": true,
  "dual_pricing": null,
  "client_details": null,
  "client_secret": "uEyLI6rmFylTwIBi",
  "customer": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
  "customer_details": {
    "email": "jenny.rosen@example.com",
    "name": "Jenny Rosen",
    "phone": null
  },
  "shipping_cost": {
    "shipping_rate": "shr_z6TEWSU3AgYq95B7KHhEg5",
    "amount": 500
  },
  "shipping_details": {
    "name": "Jenny Rosen",
    "phone": null,
    "address": {
      "line1": "510 Townsend St",
      "line2": null,
      "city": "San Francisco",
      "state": "CA",
      "postal_code": "94103",
      "country": "US"
    }
  },
  "shipping_address_collection": {
    "allowed_countries": [
      "US"
    ]
  },
  "shipping_options": [
    {
      "shipping_amount": 500,
      "shipping_rate": {
        "object": "shipping_rate",
        "id": "shr_z6TEWSU3AgYq95B7KHhEg5",
        "live": false,
        "created_at": 1750000000000,
        "updated_at": 1750000000000,
        "deleted": false,
        "active": true,
        "display_name": "Standard shipping",
        "amount": 500,
        "delivery_estimate": {
          "maximum": {
            "unit": "business_day",
            "value": 5
          },
          "minimum": {
            "unit": "business_day",
            "value": 3
          }
        },
        "metadata": {}
      }
    }
  ],
  "billing_details_collection": null,
  "phone_number_collection": false,
  "billing_details": null,
  "payments": null,
  "invoice": null,
  "subscription": null,
  "subscription_terms": null,
  "subscription_data": null,
  "mandate_text": null,
  "company_mandate_text": null,
  "line_items": [
    {
      "object": "line_item",
      "id": "li_rbw8iroSXBkFMZ8bisSxK",
      "live": false,
      "created_at": 1750000000000,
      "updated_at": 1750000000000,
      "type": "catalog",
      "quantity": 2,
      "name": null,
      "description": null,
      "unit_amount": 1000,
      "price": "price_dz1NVvl5CSogERkeA9Ng67",
      "product": "prod_KDCnId9DMZSOA9MSaut4Q",
      "discounts": [],
      "taxes": [],
      "tax_amounts": [],
      "subtotal": 2000,
      "total": 2000,
      "period": null,
      "subscription_item": null
    }
  ],
  "discounts": [
    {
      "object": "applied_discount",
      "id": "apd_lXk5TJ6ygKsjdXXRXb1DW6",
      "live": false,
      "created_at": 1750000000000,
      "discount": "di_0yejjs3V3DfgTCMZdtKIu7",
      "code": "SAVE10",
      "target": "line_items",
      "customer": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
      "name": "10% off",
      "amount_off": null,
      "percent_off": 10
    }
  ],
  "metadata": {},
  "mode": "payment",
  "payment_method_types": [
    "card",
    "us_bank_account"
  ],
  "status": "complete",
  "submit_label": "auto",
  "success_url": null,
  "url": "https://checkout.biaspay.com/uEyLI6rmFylTwIBi"
}

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

const checkoutSession = await bias.checkoutSessions.get("id");

Response example

{
  "object": "checkout_session",
  "id": "cs_MyJuJvswjRM54vPXr6qBh2",
  "live": false,
  "created_at": 1750000000000,
  "updated_at": 1750000000000,
  "total": 2300,
  "subtotal": 1800,
  "amount_collected": 2300,
  "amount_remaining": 0,
  "tax_total": 0,
  "allow_discount_codes": true,
  "dual_pricing": null,
  "client_details": null,
  "client_secret": "uEyLI6rmFylTwIBi",
  "customer": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
  "customer_details": {
    "email": "jenny.rosen@example.com",
    "name": "Jenny Rosen",
    "phone": null
  },
  "shipping_cost": {
    "shipping_rate": "shr_z6TEWSU3AgYq95B7KHhEg5",
    "amount": 500
  },
  "shipping_details": {
    "name": "Jenny Rosen",
    "phone": null,
    "address": {
      "line1": "510 Townsend St",
      "line2": null,
      "city": "San Francisco",
      "state": "CA",
      "postal_code": "94103",
      "country": "US"
    }
  },
  "shipping_address_collection": {
    "allowed_countries": [
      "US"
    ]
  },
  "shipping_options": [
    {
      "shipping_amount": 500,
      "shipping_rate": {
        "object": "shipping_rate",
        "id": "shr_z6TEWSU3AgYq95B7KHhEg5",
        "live": false,
        "created_at": 1750000000000,
        "updated_at": 1750000000000,
        "deleted": false,
        "active": true,
        "display_name": "Standard shipping",
        "amount": 500,
        "delivery_estimate": {
          "maximum": {
            "unit": "business_day",
            "value": 5
          },
          "minimum": {
            "unit": "business_day",
            "value": 3
          }
        },
        "metadata": {}
      }
    }
  ],
  "billing_details_collection": null,
  "phone_number_collection": false,
  "billing_details": null,
  "payments": null,
  "invoice": null,
  "subscription": null,
  "subscription_terms": null,
  "subscription_data": null,
  "mandate_text": null,
  "company_mandate_text": null,
  "line_items": [
    {
      "object": "line_item",
      "id": "li_rbw8iroSXBkFMZ8bisSxK",
      "live": false,
      "created_at": 1750000000000,
      "updated_at": 1750000000000,
      "type": "catalog",
      "quantity": 2,
      "name": null,
      "description": null,
      "unit_amount": 1000,
      "price": "price_dz1NVvl5CSogERkeA9Ng67",
      "product": "prod_KDCnId9DMZSOA9MSaut4Q",
      "discounts": [],
      "taxes": [],
      "tax_amounts": [],
      "subtotal": 2000,
      "total": 2000,
      "period": null,
      "subscription_item": null
    }
  ],
  "discounts": [
    {
      "object": "applied_discount",
      "id": "apd_lXk5TJ6ygKsjdXXRXb1DW6",
      "live": false,
      "created_at": 1750000000000,
      "discount": "di_0yejjs3V3DfgTCMZdtKIu7",
      "code": "SAVE10",
      "target": "line_items",
      "customer": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
      "name": "10% off",
      "amount_off": null,
      "percent_off": 10
    }
  ],
  "metadata": {},
  "mode": "payment",
  "payment_method_types": [
    "card",
    "us_bank_account"
  ],
  "status": "complete",
  "submit_label": "auto",
  "success_url": null,
  "url": "https://checkout.biaspay.com/uEyLI6rmFylTwIBi"
}

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
Filters for the list, combined with and and or.
Properties

Returns

Returns a list of checkout session objects.

List all checkout sessions

const checkoutSession = await bias.checkoutSessions.list();

Response example

{
  "object": "list",
  "items": [
    {
      "object": "checkout_session",
      "id": "cs_MyJuJvswjRM54vPXr6qBh2",
      "live": false,
      "created_at": 1750000000000,
      "updated_at": 1750000000000,
      "total": 2300,
      "subtotal": 1800,
      "amount_collected": 2300,
      "amount_remaining": 0,
      "tax_total": 0,
      "allow_discount_codes": true,
      "dual_pricing": null,
      "client_details": null,
      "client_secret": "uEyLI6rmFylTwIBi",
      "customer": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
      "customer_details": {
        "email": "jenny.rosen@example.com",
        "name": "Jenny Rosen",
        "phone": null
      },
      "shipping_cost": {
        "shipping_rate": "shr_z6TEWSU3AgYq95B7KHhEg5",
        "amount": 500
      },
      "shipping_details": {
        "name": "Jenny Rosen",
        "phone": null,
        "address": {
          "line1": "510 Townsend St",
          "line2": null,
          "city": "San Francisco",
          "state": "CA",
          "postal_code": "94103",
          "country": "US"
        }
      },
      "shipping_address_collection": {
        "allowed_countries": [
          "US"
        ]
      },
      "shipping_options": [
        {
          "shipping_amount": 500,
          "shipping_rate": {
            "object": "shipping_rate",
            "id": "shr_z6TEWSU3AgYq95B7KHhEg5",
            "live": false,
            "created_at": 1750000000000,
            "updated_at": 1750000000000,
            "deleted": false,
            "active": true,
            "display_name": "Standard shipping",
            "amount": 500,
            "delivery_estimate": {
              "maximum": {
                "unit": "business_day",
                "value": 5
              },
              "minimum": {
                "unit": "business_day",
                "value": 3
              }
            },
            "metadata": {}
          }
        }
      ],
      "billing_details_collection": null,
      "phone_number_collection": false,
      "billing_details": null,
      "payments": null,
      "invoice": null,
      "subscription": null,
      "subscription_terms": null,
      "subscription_data": null,
      "mandate_text": null,
      "company_mandate_text": null,
      "line_items": [
        {
          "object": "line_item",
          "id": "li_rbw8iroSXBkFMZ8bisSxK",
          "live": false,
          "created_at": 1750000000000,
          "updated_at": 1750000000000,
          "type": "catalog",
          "quantity": 2,
          "name": null,
          "description": null,
          "unit_amount": 1000,
          "price": "price_dz1NVvl5CSogERkeA9Ng67",
          "product": "prod_KDCnId9DMZSOA9MSaut4Q",
          "discounts": [],
          "taxes": [],
          "tax_amounts": [],
          "subtotal": 2000,
          "total": 2000,
          "period": null,
          "subscription_item": null
        }
      ],
      "discounts": [
        {
          "object": "applied_discount",
          "id": "apd_lXk5TJ6ygKsjdXXRXb1DW6",
          "live": false,
          "created_at": 1750000000000,
          "discount": "di_0yejjs3V3DfgTCMZdtKIu7",
          "code": "SAVE10",
          "target": "line_items",
          "customer": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
          "name": "10% off",
          "amount_off": null,
          "percent_off": 10
        }
      ],
      "metadata": {},
      "mode": "payment",
      "payment_method_types": [
        "card",
        "us_bank_account"
      ],
      "status": "complete",
      "submit_label": "auto",
      "success_url": null,
      "url": "https://checkout.biaspay.com/uEyLI6rmFylTwIBi"
    }
  ],
  "has_more": true
}

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_details when 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. true allows every supported country, and false or null turns collection off.
Properties
Name
billing_details_collection
Type
boolean or object or null,
Description
Which billing details checkout collects. true collects the name and full address, and false or null turns 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 total plus rate, and bank payments pay total. Defaults to the rate in your invoice settings, and null turns 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 subscription mode session creates.
Properties
Name
subscription
Type
string,
Description
In setup mode, 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

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

Response example

{
  "object": "checkout_session",
  "id": "cs_MyJuJvswjRM54vPXr6qBh2",
  "live": false,
  "created_at": 1750000000000,
  "updated_at": 1750000000000,
  "total": 2300,
  "subtotal": 1800,
  "amount_collected": 2300,
  "amount_remaining": 0,
  "tax_total": 0,
  "allow_discount_codes": true,
  "dual_pricing": null,
  "client_details": null,
  "client_secret": "uEyLI6rmFylTwIBi",
  "customer": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
  "customer_details": {
    "email": "jenny.rosen@example.com",
    "name": "Jenny Rosen",
    "phone": null
  },
  "shipping_cost": {
    "shipping_rate": "shr_z6TEWSU3AgYq95B7KHhEg5",
    "amount": 500
  },
  "shipping_details": {
    "name": "Jenny Rosen",
    "phone": null,
    "address": {
      "line1": "510 Townsend St",
      "line2": null,
      "city": "San Francisco",
      "state": "CA",
      "postal_code": "94103",
      "country": "US"
    }
  },
  "shipping_address_collection": {
    "allowed_countries": [
      "US"
    ]
  },
  "shipping_options": [
    {
      "shipping_amount": 500,
      "shipping_rate": {
        "object": "shipping_rate",
        "id": "shr_z6TEWSU3AgYq95B7KHhEg5",
        "live": false,
        "created_at": 1750000000000,
        "updated_at": 1750000000000,
        "deleted": false,
        "active": true,
        "display_name": "Standard shipping",
        "amount": 500,
        "delivery_estimate": {
          "maximum": {
            "unit": "business_day",
            "value": 5
          },
          "minimum": {
            "unit": "business_day",
            "value": 3
          }
        },
        "metadata": {}
      }
    }
  ],
  "billing_details_collection": null,
  "phone_number_collection": false,
  "billing_details": null,
  "payments": null,
  "invoice": null,
  "subscription": null,
  "subscription_terms": null,
  "subscription_data": null,
  "mandate_text": null,
  "company_mandate_text": null,
  "line_items": [
    {
      "object": "line_item",
      "id": "li_rbw8iroSXBkFMZ8bisSxK",
      "live": false,
      "created_at": 1750000000000,
      "updated_at": 1750000000000,
      "type": "catalog",
      "quantity": 2,
      "name": null,
      "description": null,
      "unit_amount": 1000,
      "price": "price_dz1NVvl5CSogERkeA9Ng67",
      "product": "prod_KDCnId9DMZSOA9MSaut4Q",
      "discounts": [],
      "taxes": [],
      "tax_amounts": [],
      "subtotal": 2000,
      "total": 2000,
      "period": null,
      "subscription_item": null
    }
  ],
  "discounts": [
    {
      "object": "applied_discount",
      "id": "apd_lXk5TJ6ygKsjdXXRXb1DW6",
      "live": false,
      "created_at": 1750000000000,
      "discount": "di_0yejjs3V3DfgTCMZdtKIu7",
      "code": "SAVE10",
      "target": "line_items",
      "customer": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
      "name": "10% off",
      "amount_off": null,
      "percent_off": 10
    }
  ],
  "metadata": {},
  "mode": "payment",
  "payment_method_types": [
    "card",
    "us_bank_account"
  ],
  "status": "complete",
  "submit_label": "auto",
  "success_url": null,
  "url": "https://checkout.biaspay.com/uEyLI6rmFylTwIBi"
}

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

const checkoutSession = await bias.checkoutSessions.expire("id");

Response example

{
  "object": "checkout_session",
  "id": "cs_MyJuJvswjRM54vPXr6qBh2",
  "live": false,
  "created_at": 1750000000000,
  "updated_at": 1750000000000,
  "total": 2300,
  "subtotal": 1800,
  "amount_collected": 2300,
  "amount_remaining": 0,
  "tax_total": 0,
  "allow_discount_codes": true,
  "dual_pricing": null,
  "client_details": null,
  "client_secret": "uEyLI6rmFylTwIBi",
  "customer": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
  "customer_details": {
    "email": "jenny.rosen@example.com",
    "name": "Jenny Rosen",
    "phone": null
  },
  "shipping_cost": {
    "shipping_rate": "shr_z6TEWSU3AgYq95B7KHhEg5",
    "amount": 500
  },
  "shipping_details": {
    "name": "Jenny Rosen",
    "phone": null,
    "address": {
      "line1": "510 Townsend St",
      "line2": null,
      "city": "San Francisco",
      "state": "CA",
      "postal_code": "94103",
      "country": "US"
    }
  },
  "shipping_address_collection": {
    "allowed_countries": [
      "US"
    ]
  },
  "shipping_options": [
    {
      "shipping_amount": 500,
      "shipping_rate": {
        "object": "shipping_rate",
        "id": "shr_z6TEWSU3AgYq95B7KHhEg5",
        "live": false,
        "created_at": 1750000000000,
        "updated_at": 1750000000000,
        "deleted": false,
        "active": true,
        "display_name": "Standard shipping",
        "amount": 500,
        "delivery_estimate": {
          "maximum": {
            "unit": "business_day",
            "value": 5
          },
          "minimum": {
            "unit": "business_day",
            "value": 3
          }
        },
        "metadata": {}
      }
    }
  ],
  "billing_details_collection": null,
  "phone_number_collection": false,
  "billing_details": null,
  "payments": null,
  "invoice": null,
  "subscription": null,
  "subscription_terms": null,
  "subscription_data": null,
  "mandate_text": null,
  "company_mandate_text": null,
  "line_items": [
    {
      "object": "line_item",
      "id": "li_rbw8iroSXBkFMZ8bisSxK",
      "live": false,
      "created_at": 1750000000000,
      "updated_at": 1750000000000,
      "type": "catalog",
      "quantity": 2,
      "name": null,
      "description": null,
      "unit_amount": 1000,
      "price": "price_dz1NVvl5CSogERkeA9Ng67",
      "product": "prod_KDCnId9DMZSOA9MSaut4Q",
      "discounts": [],
      "taxes": [],
      "tax_amounts": [],
      "subtotal": 2000,
      "total": 2000,
      "period": null,
      "subscription_item": null
    }
  ],
  "discounts": [
    {
      "object": "applied_discount",
      "id": "apd_lXk5TJ6ygKsjdXXRXb1DW6",
      "live": false,
      "created_at": 1750000000000,
      "discount": "di_0yejjs3V3DfgTCMZdtKIu7",
      "code": "SAVE10",
      "target": "line_items",
      "customer": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
      "name": "10% off",
      "amount_off": null,
      "percent_off": 10
    }
  ],
  "metadata": {},
  "mode": "payment",
  "payment_method_types": [
    "card",
    "us_bank_account"
  ],
  "status": "complete",
  "submit_label": "auto",
  "success_url": null,
  "url": "https://checkout.biaspay.com/uEyLI6rmFylTwIBi"
}

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 id to 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. true allows every supported country, and false or null turns collection off.
Properties
Name
billing_details_collection
Type
boolean or object or null,
Description
Which billing details checkout collects. true collects the name and full address, and false or null turns 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 null to 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 total plus rate, and bank payments pay total.
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

const checkoutSession = await bias.checkoutSessions.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,
  "updated_at": 1750000000000,
  "total": 2300,
  "subtotal": 1800,
  "amount_collected": 2300,
  "amount_remaining": 0,
  "tax_total": 0,
  "allow_discount_codes": true,
  "dual_pricing": null,
  "client_details": null,
  "client_secret": "uEyLI6rmFylTwIBi",
  "customer": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
  "customer_details": {
    "email": "jenny.rosen@example.com",
    "name": "Jenny Rosen",
    "phone": null
  },
  "shipping_cost": {
    "shipping_rate": "shr_z6TEWSU3AgYq95B7KHhEg5",
    "amount": 500
  },
  "shipping_details": {
    "name": "Jenny Rosen",
    "phone": null,
    "address": {
      "line1": "510 Townsend St",
      "line2": null,
      "city": "San Francisco",
      "state": "CA",
      "postal_code": "94103",
      "country": "US"
    }
  },
  "shipping_address_collection": {
    "allowed_countries": [
      "US"
    ]
  },
  "shipping_options": [
    {
      "shipping_amount": 500,
      "shipping_rate": {
        "object": "shipping_rate",
        "id": "shr_z6TEWSU3AgYq95B7KHhEg5",
        "live": false,
        "created_at": 1750000000000,
        "updated_at": 1750000000000,
        "deleted": false,
        "active": true,
        "display_name": "Standard shipping",
        "amount": 500,
        "delivery_estimate": {
          "maximum": {
            "unit": "business_day",
            "value": 5
          },
          "minimum": {
            "unit": "business_day",
            "value": 3
          }
        },
        "metadata": {}
      }
    }
  ],
  "billing_details_collection": null,
  "phone_number_collection": false,
  "billing_details": null,
  "payments": null,
  "invoice": null,
  "subscription": null,
  "subscription_terms": null,
  "subscription_data": null,
  "mandate_text": null,
  "company_mandate_text": null,
  "line_items": [
    {
      "object": "line_item",
      "id": "li_rbw8iroSXBkFMZ8bisSxK",
      "live": false,
      "created_at": 1750000000000,
      "updated_at": 1750000000000,
      "type": "catalog",
      "quantity": 2,
      "name": null,
      "description": null,
      "unit_amount": 1000,
      "price": "price_dz1NVvl5CSogERkeA9Ng67",
      "product": "prod_KDCnId9DMZSOA9MSaut4Q",
      "discounts": [],
      "taxes": [],
      "tax_amounts": [],
      "subtotal": 2000,
      "total": 2000,
      "period": null,
      "subscription_item": null
    }
  ],
  "discounts": [
    {
      "object": "applied_discount",
      "id": "apd_lXk5TJ6ygKsjdXXRXb1DW6",
      "live": false,
      "created_at": 1750000000000,
      "discount": "di_0yejjs3V3DfgTCMZdtKIu7",
      "code": "SAVE10",
      "target": "line_items",
      "customer": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
      "name": "10% off",
      "amount_off": null,
      "percent_off": 10
    }
  ],
  "metadata": {},
  "mode": "payment",
  "payment_method_types": [
    "card",
    "us_bank_account"
  ],
  "status": "complete",
  "submit_label": "auto",
  "success_url": null,
  "url": "https://checkout.biaspay.com/uEyLI6rmFylTwIBi"
}

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

const discountCode = await bias.checkoutSessions.discountCode.apply("id");

Response example

{
  "object": "checkout_session",
  "id": "cs_MyJuJvswjRM54vPXr6qBh2",
  "live": false,
  "created_at": 1750000000000,
  "updated_at": 1750000000000,
  "total": 2300,
  "subtotal": 1800,
  "amount_collected": 2300,
  "amount_remaining": 0,
  "tax_total": 0,
  "allow_discount_codes": true,
  "dual_pricing": null,
  "client_details": null,
  "client_secret": "uEyLI6rmFylTwIBi",
  "customer": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
  "customer_details": {
    "email": "jenny.rosen@example.com",
    "name": "Jenny Rosen",
    "phone": null
  },
  "shipping_cost": {
    "shipping_rate": "shr_z6TEWSU3AgYq95B7KHhEg5",
    "amount": 500
  },
  "shipping_details": {
    "name": "Jenny Rosen",
    "phone": null,
    "address": {
      "line1": "510 Townsend St",
      "line2": null,
      "city": "San Francisco",
      "state": "CA",
      "postal_code": "94103",
      "country": "US"
    }
  },
  "shipping_address_collection": {
    "allowed_countries": [
      "US"
    ]
  },
  "shipping_options": [
    {
      "shipping_amount": 500,
      "shipping_rate": {
        "object": "shipping_rate",
        "id": "shr_z6TEWSU3AgYq95B7KHhEg5",
        "live": false,
        "created_at": 1750000000000,
        "updated_at": 1750000000000,
        "deleted": false,
        "active": true,
        "display_name": "Standard shipping",
        "amount": 500,
        "delivery_estimate": {
          "maximum": {
            "unit": "business_day",
            "value": 5
          },
          "minimum": {
            "unit": "business_day",
            "value": 3
          }
        },
        "metadata": {}
      }
    }
  ],
  "billing_details_collection": null,
  "phone_number_collection": false,
  "billing_details": null,
  "payments": null,
  "invoice": null,
  "subscription": null,
  "subscription_terms": null,
  "subscription_data": null,
  "mandate_text": null,
  "company_mandate_text": null,
  "line_items": [
    {
      "object": "line_item",
      "id": "li_rbw8iroSXBkFMZ8bisSxK",
      "live": false,
      "created_at": 1750000000000,
      "updated_at": 1750000000000,
      "type": "catalog",
      "quantity": 2,
      "name": null,
      "description": null,
      "unit_amount": 1000,
      "price": "price_dz1NVvl5CSogERkeA9Ng67",
      "product": "prod_KDCnId9DMZSOA9MSaut4Q",
      "discounts": [],
      "taxes": [],
      "tax_amounts": [],
      "subtotal": 2000,
      "total": 2000,
      "period": null,
      "subscription_item": null
    }
  ],
  "discounts": [
    {
      "object": "applied_discount",
      "id": "apd_lXk5TJ6ygKsjdXXRXb1DW6",
      "live": false,
      "created_at": 1750000000000,
      "discount": "di_0yejjs3V3DfgTCMZdtKIu7",
      "code": "SAVE10",
      "target": "line_items",
      "customer": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
      "name": "10% off",
      "amount_off": null,
      "percent_off": 10
    }
  ],
  "metadata": {},
  "mode": "payment",
  "payment_method_types": [
    "card",
    "us_bank_account"
  ],
  "status": "complete",
  "submit_label": "auto",
  "success_url": null,
  "url": "https://checkout.biaspay.com/uEyLI6rmFylTwIBi"
}

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.

Remove a discount code

const discountCode = await bias.checkoutSessions.discountCode.remove("id");

Response example

{
  "object": "checkout_session",
  "id": "cs_MyJuJvswjRM54vPXr6qBh2",
  "live": false,
  "created_at": 1750000000000,
  "updated_at": 1750000000000,
  "total": 2300,
  "subtotal": 1800,
  "amount_collected": 2300,
  "amount_remaining": 0,
  "tax_total": 0,
  "allow_discount_codes": true,
  "dual_pricing": null,
  "client_details": null,
  "client_secret": "uEyLI6rmFylTwIBi",
  "customer": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
  "customer_details": {
    "email": "jenny.rosen@example.com",
    "name": "Jenny Rosen",
    "phone": null
  },
  "shipping_cost": {
    "shipping_rate": "shr_z6TEWSU3AgYq95B7KHhEg5",
    "amount": 500
  },
  "shipping_details": {
    "name": "Jenny Rosen",
    "phone": null,
    "address": {
      "line1": "510 Townsend St",
      "line2": null,
      "city": "San Francisco",
      "state": "CA",
      "postal_code": "94103",
      "country": "US"
    }
  },
  "shipping_address_collection": {
    "allowed_countries": [
      "US"
    ]
  },
  "shipping_options": [
    {
      "shipping_amount": 500,
      "shipping_rate": {
        "object": "shipping_rate",
        "id": "shr_z6TEWSU3AgYq95B7KHhEg5",
        "live": false,
        "created_at": 1750000000000,
        "updated_at": 1750000000000,
        "deleted": false,
        "active": true,
        "display_name": "Standard shipping",
        "amount": 500,
        "delivery_estimate": {
          "maximum": {
            "unit": "business_day",
            "value": 5
          },
          "minimum": {
            "unit": "business_day",
            "value": 3
          }
        },
        "metadata": {}
      }
    }
  ],
  "billing_details_collection": null,
  "phone_number_collection": false,
  "billing_details": null,
  "payments": null,
  "invoice": null,
  "subscription": null,
  "subscription_terms": null,
  "subscription_data": null,
  "mandate_text": null,
  "company_mandate_text": null,
  "line_items": [
    {
      "object": "line_item",
      "id": "li_rbw8iroSXBkFMZ8bisSxK",
      "live": false,
      "created_at": 1750000000000,
      "updated_at": 1750000000000,
      "type": "catalog",
      "quantity": 2,
      "name": null,
      "description": null,
      "unit_amount": 1000,
      "price": "price_dz1NVvl5CSogERkeA9Ng67",
      "product": "prod_KDCnId9DMZSOA9MSaut4Q",
      "discounts": [],
      "taxes": [],
      "tax_amounts": [],
      "subtotal": 2000,
      "total": 2000,
      "period": null,
      "subscription_item": null
    }
  ],
  "discounts": [
    {
      "object": "applied_discount",
      "id": "apd_lXk5TJ6ygKsjdXXRXb1DW6",
      "live": false,
      "created_at": 1750000000000,
      "discount": "di_0yejjs3V3DfgTCMZdtKIu7",
      "code": "SAVE10",
      "target": "line_items",
      "customer": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
      "name": "10% off",
      "amount_off": null,
      "percent_off": 10
    }
  ],
  "metadata": {},
  "mode": "payment",
  "payment_method_types": [
    "card",
    "us_bank_account"
  ],
  "status": "complete",
  "submit_label": "auto",
  "success_url": null,
  "url": "https://checkout.biaspay.com/uEyLI6rmFylTwIBi"
}