Create a cart

A cart can be created using products that exist in the Nexway catalog by referencing them with their UUID or by using signed products. You will find some examples below.

Request

POST https://api.nexway.store/carts/public

Request body

The request body takes a complete CartInput resource, containing the following writable properties:

{
    "checkoutUrl": "string",
    "country": "string",
    "discounts": [
        "string"
    ],
    "endUser": {
        "city": "string",
        "company": {
            "companyName": "string",
            "validVatNumber": "boolean",
            "vatNumber": "string"
        },
        "country": "string",
        "email": "string",
        "firstName": "string",
        "id": "string",
        "lastName": "string",
        "locale": "string",
        "streetAddress": "string",
        "zipCode": "string"
    },
    "externalContext": "string",
    "locale": "string",
    "products": {
        "<key>": {
            "priceFunctionParameters": {
                "<key>": "string"
            },
            "quantity": "int32"
        }
    },
    "salesFlag": [
        "string"
    ],
    "storeHostname": "string",
    "storeId": "string"
}

Properties

Name Type Description Additional
checkoutUrl string

The full url use to cart

Optional
country string

Country to the cart

discounts[] array of string

List of signed discounts

Optional
endUser object EndUser Optional
endUser.city string

Address book city

Optional
endUser.company object Company Optional
endUser.company.companyName string

Enduser company name

endUser.company.validVatNumber boolean Optional
endUser.company.vatNumber string

Company vat number

Optional
endUser.country string

This is the country end user.

Optional
endUser.email string

This is the email end user.

endUser.firstName string

End user first name

Optional
endUser.id string

This is the reference id of the end user service.

Optional
endUser.lastName string

End user last name

Optional
endUser.locale string

End user locale

endUser.streetAddress string

Address book street address

endUser.zipCode string

Address book zipCode

externalContext string

External context

Optional
locale string

Locale to the cart

products object

map of products id or signed product in the cart with its quantity

products.<key> map of object ProductInput Optional
products.<key>.priceFunctionParameters object

Parameters of the product

products.<key>.priceFunctionParameters.<key> map of string Optional
products.<key>.quantity int32

This is the product quantity.

salesFlag[] array of string

List of sales flag

Optional
storeHostname string

The hostname of store

Optional
storeId string

Reference ID of the store service.

Response

The following HTTP status codes may be returned, optionally with a response resource.

Status code Description Resource
201 Created

Success

Success
401 Unauthorized

Unauthorized

403 Forbidden

Forbidden

404 Not Found

Not Found

500 Internal Server Error

Failure

Example with a nexway product

We can add products known and stored by Nexway to the cart by using their product IDs:

{
    "country": "US",
    "endUser": {
        "city": "San Francisco",
        "country": "US",
        "email": "jdoe@com2us.com",
        "firstName": "Doe",
        "lastName": "John",
        "locale": "en-US",
        "streetAddress": "236 8th street",
        "zipCode": "94103"
    },
    "locale": "en-US",
    "ip": "82.238.87.229",
    "products": {
        "82fc0517-358a-49a8-b5fb-8be1a0ced674": {
            "quantity": "2"
        }
    },
    "storeId": "82fc0517-358a-49a8-b5fb-8be1a0ced674"
}

Example with a signed product (catalog-free)

You can directly define product information when creating the cart without the product needing to be known upstream in the Nexway system.
To do so, you need to add a signed product in the cart instead of a product ID.
To learn more about signing data, please read Sign data.

Two different formats are possible:

  • Private product
    This payload is exactly the same that we expect when we create a product.
  • Public product
    If not found, some fields of this payload are filled by default, for example:
    • lifeTime equal to PERMANENT
    • type equal to SOFTWARE
    • customerId equal to the customer ID associated with the store
    • storeId equal to the store ID associated with the product

Below is an example of a minimal public product before signing:

{
    publisherRefId: "SKU001",
    name: "product name",
    price: {
        grossPrice: 178.5,
        currency: "EUR"
    }
}

Below is an example of a cart with a signed product:

{
    "country": "US",
    "endUser": {
        "city": "San Francisco",
        "country": "US",
        "email": "jdoe@com2us.com",
        "firstName": "Doe",
        "lastName": "John",
        "locale": "en-US",
        "streetAddress": "236 8th street",
        "zipCode": "94103"
    },
    "locale": "en-US",
    "ip": "82.238.87.229",
    "products": {
        "ewogICAgInB1Ymxpc2hlclJlZklkIjogIlNLVTAwMSIsCiAgICAibmFtZSI6ICJwcm9kdWN0IG5hbWUiLAogICAgInByaWNlIjogewogICAgICAgICJncm9zc1ByaWNlIjogMTc4LjUsCiAgICAgICAgImN1cnJlbmN5IjogIkVVUiIKICAgIH0KfS0tLS1NQ3dDRkVVaVA5UHozd3IrYVBzdkZkNzJVdklnelYvU0FoUmFGb2ZDRXRrN3RCNTZZb1ROelNIeENIT2ZQQT09": {
            "quantity": "2"
        }
    },
    "storeId": "82fc0517-358a-49a8-b5fb-8be1a0ced674"
}

Explore this API

cart

cart

Request Content-Type
Response Content-Type
Try it out!