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:

{
    "country": "string",
    "discounts": [
        "string"
    ],
    "endUser": {
        "city": "string",
        "country": "string",
        "email": "string",
        "firstName": "string",
        "id": "string",
        "lastName": "string",
        "locale": "string",
        "storeId": "string",
        "streetAddress": "string",
        "zipCode": "string"
    },
    "locale": "string",
    "products": {
        "<key>": {
            "quantity": "int32"
        }
    },
    "storeId": "string"
}

Properties

Name Type Description Additional
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

endUser.country string

End user country (format ISO 3166-1 alpha-2)

endUser.email string

End user email

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.storeId string

Store id

Optional
endUser.streetAddress string

Address book street address

endUser.zipCode string

Address book zipCode

Optional
locale string

Locale to the cart

products object

map of products id in the cart with its quantity

products.<key> map of object ProductInput Optional
products.<key>.quantity int32

This is the product quantity.

storeId string

This is the 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!