Create a cart

A cart can be created using products existing in the Nexway catalog referencing them by their UUID or using signed products. Below, you will find some examples.

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

In the cart we can add products via their product IDs (products known and stored by Nexway)

{
    "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 less)

You can directly define product information when creating the cart without this product needing to be known upstream in our system.
To do so you have to add a signed product in the cart instead of product ID.
About the signing of data, please read Sign data.

Two different format are possible:

  • Private product
    This payload is exactly the same that expected when we create a product.
  • Public product
    Some fields of this payload will be filled by default if not found:
    • lifeTime equal to PERMANENT
    • type equal to SOFTWARE
    • customerId equal to the customer ID of store
    • storeId equal the to store ID of product

Below, the minimal public product to sign:

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

To sum up, 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!