A client session is the starting point for integrating payments with Universal Checkout. You can attach all the metadata associated with the order to the client session, and generate a clientToken, a temporary key used to initialize Universal Checkout.

The information you include in the client session is used in the Dashboard:

  • to conditionally route payments with Workflows
  • to activate payment methods and other features in Universal Checkout.

So pass as much information as you can!


The clientToken is a key concept within Primer. You may receive a client token from various places but as long as you pass it to the SDK, Universal Checkout knows where to start/resume the flow.

Create a client session

On your server, create a client session with POST /client-session.

Make sure to pass at least the following data:

orderIdYour reference for the payment.

Make sure to keep track of orderId - you will later receive updates to the payment via Webhooks. The payment will contain the orderId specified in the client session.
currencyCodeThe three-letter currency code in ISO 4217 format.
e.g. use USD for US dollars.
order.lineItemsThe details of the line items of the order.

Use the metadata field to attach arbitrary data. Use this to build custom conditions in Workflows for routing and A/B testing.

Data you pass when creating a client session is used when creating a payment, unless explicitly overwritten.

Make sure to pass all the information required by the payment methods and features activated on your Dashboard.

Example request:

curl --location --request \ POST 'https://api.sandbox.primer.io/client-session' \ --header 'X-Api-Key: <YOUR_API_KEY>' \ --header 'X-Api-Version: 2.1' \ --data '{    "orderId": "<YOUR_ORDER_ID>",    "currencyCode": "GBP",    "amount": 4999,    "order": {      "lineItems": [{        "itemId": "shoes-123",        "description": "Some shoes",        "amount": 2500,        "quantity": 2      }]    } }'

The body of a successful response contains a clientToken that you will use to initialize Universal Checkout.

Check the warnings array for missing data which may be required to display certain payment methods and checkout modules in the Universal Checkout.

{    "clientToken": "<THE_CLIENT_TOKEN>",    "clientTokenExpirationDate": "2021-08-12T16:14:08.578695",    "orderId": "<YOUR_ORDER_ID>",    "currencyCode": "GBP",    "amount": 5000,    "customerId": "<YOUR_CUSTOMER_ID>",    "metadata": {},    "warnings": ["Apple Pay is missing 'customerDetails.countryCode'"]}
️ As a `clientToken` is a temporary key, it has an expiration time of 24 hours.

Update a client session

Universal Checkout automatically updates the Client Session as it captures more data such as the billing address.

Alternatively, you can manually update the Client Session to update the line items or the customer details.

This feature is currently only available on our Web Drop-in Checkout.

Make a request to PATCH /client-session to update the Client Session tied to a Client Token.

curl --location --request \ PATCH 'https://api.sandbox.primer.io/client-session' \ --header 'X-Api-Key: <YOUR_API_KEY>' \ --header 'X-Api-Version: 2.2' \ --data '{    "clientToken": "<CLIENT_TOKEN>",    "order": {      "lineItems": [{        "itemId": "shoes-123",        "description": "Some shoes",        "amount": 2500,        "quantity": 1      }]    } }'

Then, call refreshClientSession() to ask Universal Checkout to get the latest client session.

// With Drop-in Checkoutconst checkout = await Primer.showUniversalCheckout(clientToken, options)
// Refresh the internal client sessionawait checkout.refreshClientSession()