GoDaddy

Checkout session reference

View as Markdown

The identifiers, order formats, checkout sections, and response object of a Unified Checkout session.

Overview

createCheckoutSession takes a single input object that requires a storeId, an order (as lineItems or a draftOrderId), and public HTTPS return URLs. Everything else is optional.

This page lists the identifiers, order formats, session options, checkout sections, and the object a session returns. Go to How to configure checkout for how to use payment methods and the collect and offer options. Go to How to create a checkout session for the implementation steps, limits, and common errors.

Identifiers and URLs

The following table lists the identifiers and URLs a session accepts.

FieldTypeRequiredDescription
storeIdstringYesThe store the payment belongs to
returnUrlstringYesWhere the shopper goes after cancelling
successUrlstringYesWhere the shopper goes after paying
channelIdstringNoSales channel for the order. Defaults to the store's default channel
businessIdstringNoResponse only. GoDaddy resolves it from the store
expiresAtstringNoSet when you want the session to stop being usable

Use public HTTPS URLs for returnUrl and successUrl. Checkout rejects loopback URLs like localhost and 127.0.0.1 before creating the session, so local development needs a tunnel that gives you a public hostname.

Checkout doesn't expand placeholders in successUrl. Checkout stores a ${orderId} you write into the URL and returns it exactly as you sent it.

How you add an order ID depends on the checkout form. Embedded checkout reads successUrl from the session object your server passes to the browser, so you can read draftOrder.id off the created session and rewrite the URL before handing it over. Hosted checkout reads the stored value instead, so the URL has to be final before you create the session: create the draft order first and pass draftOrderId if you need its ID in the URL.

Ways to supply the order

An order reaches a session through one of two fields (lineItems or draftOrderId), never both.

Each entry in lineItems then takes one of two forms. Define the product inline when your own system owns the cart:

{
  lineItems: [
    {
      quantity: 2,
      lineItemData: {
        name: 'T-Shirt',
        priceData: { currencyCode: 'USD', unitAmount: 1999 },
      },
    },
  ],
}

unitAmount is in the currency's minor unit, so 1999 is $19.99.

Reference products already in your GoDaddy catalog by SKU:

{
  lineItems: [{ skuId: process.env.SKU_ID, quantity: 1 }],
}

The other field points at an order you created earlier:

{
  draftOrderId: process.env.DRAFT_ORDER_ID,
}

When you pass lineItems, GoDaddy creates the draft order for you and returns it on the session. That means a session needs no pre-existing order.

A session accepts a maximum of 20 line items, and every line item must use the same currency.

Session options

The following table lists the optional fields that control payment methods and what the form collects and offers, and where each one is described:

FieldTypeControlsDescribed in
paymentMethodsobjectWhich methods checkout offers, with processor and checkoutTypes for eachChoose payment methods
enablePhoneCollectionbooleanCollect a phone numberWhat checkout collects
enableNotesCollectionbooleanAccept an order noteWhat checkout collects
enableShippingAddressCollectionbooleanCollect a shipping addressWhat checkout collects
enableBillingAddressCollectionbooleanCollect a billing addressWhat checkout collects
enableAddressAutocompletebooleanSuggest addresses as the shopper typesWhat checkout collects
enableShippingbooleanCollect a shipping methodWhat checkout offers
enableLocalPickupbooleanOffer pickup at a location you defineWhat checkout offers
enableTaxCollectionbooleanCalculate tax on the orderWhat checkout offers
enablePromotionCodesbooleanAccept a discount codeWhat checkout offers
enableTipsbooleanOffer a tipWhat checkout offers
locationsarrayPickup locationsPickup locations and hours
operatingHoursobjectPickup hours and time slotsPickup locations and hours
enabledLocalesarrayLanguages checkout allowsSet the checkout language

Checkout sections

Each session flag maps to one or more sections in the checkout form. The following table lists when each section appears.

SectionAppears whenNote
contactAlways
paymentAlways
deliveryenableShipping or enableLocalPickup is set, and the order isn't digital-only
shippingenableShipping is set and the shopper chooses shipping
pickupenableLocalPickup is set and the shopper chooses pickupNeeds locations, and operatingHours for time slots
tipsenableTips is set
express-checkoutA payment method offers express, enableShipping is set, and the order total is greater than 0
notesenableNotesCollection is set and delivery is offWith delivery on, the note field renders inside the shipping or pickup section instead

shipping and pickup are the two halves of one choice, so at most one is ever on screen. With both flags set, the shopper picks between them in the delivery section. To offer only one, set the other flag to false explicitly. Leaving it out isn't the same as turning it off.

What the session returns

createCheckoutSession returns the following object:

{
  "id": "$SESSION_ID",
  "token": "$SESSION_TOKEN",
  "url": ".../c/$SESSION_ID#$SESSION_TOKEN",
  "storeId": "$STORE_ID",
  "businessId": "$BUSINESS_ID",
  "channelId": "$CHANNEL_ID",
  "draftOrder": {
    "id": "$ORDER_ID",
    "statuses": { "status": "DRAFT" },
    "totals": { "total": { "currencyCode": "USD", "value": 1099 } }
  },
  "paymentMethods": { "card": { "processor": "godaddy", "checkoutTypes": ["standard"] } },
  "successUrl": "$SUCCESS_URL",
  "returnUrl": "$RETURN_URL"
}

The sample is trimmed to the fields you act on. A real session also echoes back every option you set, along with the shipping origin, any pickup locations, and the appearance values.

The id and token together authenticate every later call. Embedded checkout passes the whole object to the checkout component. Hosted checkout sends the shopper to url, which carries the token in its fragment so it never reaches a server.

Use the url the session returns. Don't construct it yourself.

Go to How to create a checkout session for session create error messages and what to change.

Last updated on

How is this guide?

On this page