Prerequisites
Before being able to start using Shopper API, make sure you have followed the get-started guide for prerequisites in configuration and management API requirements.
Session
Overview
When you initiate a session, it will generate a cart and a token (JWT) for subsequent calls. Sessions are not only the gateway to initiating a checkout but also encapsulate all the necessary transactional and cart details.
Starting a Session and Response Structure
When you start a session by making a POST call to /sessions/start
, the API returns a JSON response containing the following:
- Transactional Information: Price, total amount, taxes, etc.
- Cart Content Details: Items in the cart, their attributes, and quantities.
Session
Field | Type | Description |
---|---|---|
id | string | The unique identifier for the session. |
storeGroupId | string | The group ID of the store. |
countryCode | string | Country code of the session. |
languageCode | string | Language code of the session. |
currencyCode | string | Currency code applicable to this session. |
cart | object | Details about the cart in the session (described in the next table). |
jwt | string | The JSON Web Token to be used for authenticating subsequent calls. |
createdAt | string | Timestamp marking the creation of the session. |
expiresAt | string | Timestamp marking the expiration date of the session. |
totalAmount | integer | The total amount for the session including tax, in cents. |
totalTaxAmount | integer | The total tax amount for the session, in cents. |
paymentStatus | string | The payment status of the session (PENDING , PAID , etc.). |
Cart Object
Field | Type | Description |
---|---|---|
id | string | Unique identifier for the cart. |
items | array | Array of cart items, each containing attributes like SKU, price, etc. |
discountCode | string | The discount code applied to the cart, if any. |
discountAmount | integer | The total amount of discount applied to the cart, in cents. |
subTotalAmount | integer | The subtotal amount before any discounts are applied, in cents. |
totalAmount | integer | The final total amount including all discounts, in cents. |
totalTaxAmount | integer | The total tax amount for the cart, in cents. |
For a more detailed understanding of each attribute, you can refer to API Reference (Shopper).
Operations
- Add Item: POST
/sessions/items
- Update Item: PUT
/sessions/items
- Add Discount Code: POST
/sessions/discount-code
The response will include all transactional information as well as cart content related details. See schema in API Refernce for detailed description.
Session Expiry
A session will end either with a successful checkout or after 30 days.