Skip to main content

Create a checkout session

Checkout sessions allow your consumer to initiate a purchase on your web app. The checkout session token you receive is what allows you to utilize the capabilities of the Checkout API, such as Drop-in UI and Hosted Payments Page (HPP).

How it works

  1. The consumer initiates a checkout with your server via their browser.
  2. Your server then sends an authentication request via the Checkout API.
  3. If authentication is successful, an accessToken (bearer token) is sent in response to your server.
  4. Your server then creates a checkout session by sending a POST request to the /checkout/intent endpoint, using the accessToken, the merchant ID, an order reference, and a cart object.
  5. The Checkout API sends the checkoutSessionToken as a response to your server, which is then sent to the consumer’s browser.
  6. The webpage loads the checkout feature you chose (Drop-in UI or HPP) and initializes it with the checkoutSessionToken.

The following settings can help you better utilize the Checkout API for your business needs.

Checkout session scenarios and settings
Setting Scenario description

Set authorizationType = TOKENIZE_ONLY

Use this to get the tokens for the cards or bank accounts without going through Zero Dollar Authorization (ZDA).

Set captureMethod = CAPTURE_METHOD_MANUAL

Use this to authorize and manually capture a payment via the Payments API. Learn more about how to authorize and capture a payment.

Set captureMethod = CAPTURE_METHOD_NOW

Use this to authorize and automatically capture a payment.
Set isSaveConsumerProfile = true

Use this to store consumer details so they don’t have to re-enter the information next time.

When set to true, Payments API makes a call to consumer profile to either create a new profile or retrieve an existing profile at the time of making the payment.

The following is a sample request to create a checkout session and provide the checkoutSessionToken.

Method: POST

Endpoint: /checkout/intent

Javascript
const config = {
   method: "POST",
   headers: {
      "Content-Type": "application/json",
      "Authorization": "Bearer ${accessToken}",
      "requestId": "merchantOrderReference",
      "merchantId": "merchantId"
     },
   body: JSON.stringify(sessionRequestPayload)
};
const response = await fetch(ENDPOINT,config);
Tip
  • The accessToken (or bearer token) is what you receive from the Checkout API.
  • The sessionRequestPayload in the JavaScript expresses your checkout intents and configurations, which controls what your consumers see on the checkout form.

The following is a sessionRequestPayload sample request to express the intent to authorize and capture $55.00 USD:

Json
{
    "currencyCode": "USD",
    "merchantOrderNumber": "X1G5VZMxplIm1tRRcrC85o",
    "checkoutOptions": {
        "authorization": {
            "authorizationType": "AUTH_METHOD_CART_AMOUNT"
        },
        "capture": {
            "captureMethod": "CAPTURE_METHOD_NOW"
        }
    },
    "cart": {
        "totalTransactionAmount": 1000
    }
}

Response:

Json
{
    "checkoutSessionToken": "exampleCh3ck0utT0k3n"
}

Your backend server returns the checkoutSessionToken back to your web app, where it will be used to render the Checkout form using the JavaScript library.

Drop-in UI

Hosted Payments Page

Pay by Link

Authorize and capture a payment