Skip to main content

Checkout

The final step of using the Storefront API for Amazon Business is to add the product to the shopping cart.

caution

Our API does not perform the order, you need to redirect to the URL returned when Direct Order is disabled or use the returned Cart item to initiate the order process by your own.

The checkout process is sligly different if the Direct Order option is enabled for your account.

Direct Order enabled

If Direct Order is enabled for your account, you need to use an access token (YOUR_ACCESS_TOKEN) to authenticate your request. You will also need to pass the YOUR_PRODUCT_ID again to initiate the checkout process, together with an AMAZON_OFFER_ID, returned on the Product Details endpoint, and a positive QUANTITY.

curl --request POST \
--header 'authorization: YOUR_ACCESS_TOKEN' \
--url 'https://YOUR_DOMAIN/api/v1/amazon/products/YOUR_PRODUCT_ID/checkout'
--data '{"amazonOfferId": "AMAZON_OFFER_ID", "quantity": QUANTITY}'

Parameters

ParameterDescription
amazonOfferIdA current offer id returned by the product details endpoint.
quantityQuantity to be added to reserved.

Response

If everything goes well, you will receive a successful HTTP response with status 200 OK with a payload containing a cart item that you can use to initiate the order by your own.

{
"type": "direct-order",
"item": {
"id": 1000000043,
"productId": "s_CgpCMDc5OEg0NkNNEAIaAkRFIgVlbi1HQii4hT0",
"offerId": "DloG1%2BEdh%2F7zO1JBKctxp99vTXI5d2P5RAEZda1iy8dwbayrz8HeH8r1lf0nOy73CM4mEVL3aF0bLyGWFRAc8R77383LFqJ7ThaCYRAo3BWdJijsBZT8Xw5CtopQMaBxabXwZ%2F%2Bd3IvyCn2qrNsv%2B4yc8r0kDBip9zWIocM2MvRqmvhaFFdUeg%3D%3D",
"vendorName": "Amazon Business",
"catalogName": "Amazon Business (DE)",
"sku": "B0798H46CM",
"asin": "B0798H46CM",
"name": "Apple iPhone 8 (refurbished), 64GB",
"imageURL": "https://m.media-amazon.com/images/I/31RN1gbmjjL._SY500_.jpg",
"quantity": 2,
"canChangeQuantity": true,
"price": {
"amount": "119.99",
"currency": "EUR"
},
"priceUnit": "per ",
"priceQuantity": 1,
"quantityMin": 1,
"quantityMax": 4,
"manufacturer": "Apple",
"erpNumber": "AMAZON",
"externalId": "DloG1%2BEdh%2F7zO1JBKctxp99vTXI5d2P5RAEZda1iy8dwbayrz8HeH8r1lf0nOy73CM4mEVL3aF0bLyGWFRAc8R77383LFqJ7ThaCYRAo3BWdJijsBZT8Xw5CtopQMaBxabXwZ%2F%2Bd3IvyCn2qrNsv%2B4yc8r0kDBip9zWIocM2MvRqmvhaFFdUeg%3D%3D",
"unspsc": "43191501",
"isService": false,
"extProductId": "DloG1%2BEdh%2F7zO1JBKctxp99vTXI5d2P5RAEZda1iy8dwbayrz8HeH8r1lf0nOy73CM4mEVL3aF0bLyGWFRAc8R77383LFqJ7ThaCYRAo3BWdJijsBZT8Xw5CtopQMaBxabXwZ%2F%2Bd3IvyCn2qrNsv%2B4yc8r0kDBip9zWIocM2MvRqmvhaFFdUeg%3D%3D",
"shippingTotals": {
"amount": "0",
"currency": "EUR"
},
"taxTotals": {
"amount": "0",
"currency": "EUR"
}
}
}

Direct Order disabled

If Direct Order is disabled for your account, you need to use an access token (YOUR_ACCESS_TOKEN) to authenticate your request. You will also need to pass the YOUR_PRODUCT_ID again to initiate the checkout process. Finally, we will need a YOUR_HOOK_URL that we will use to return the shopping cart to your system as it is returned by Amazon.

curl --request POST \
--header 'authorization: YOUR_ACCESS_TOKEN' \
--url 'https://YOUR_DOMAIN/api/v1/amazon/products/YOUR_PRODUCT_ID/checkout'
--data '{"callbackUrl": "YOUR_HOOK_URL"}'

Parameters

ParameterDescription
callbackUrlSet this to the URL you want Storefront to postback the shopping cart in OCI format.
name(optional) Name of the shopper.
shipTo(optional) Address that Amazon should use for sending the order.

Shipment address

The parameters of the shipment address are the same as those in the cXML specification.

ParameterDescription
addressId(optional) ID of the address.
addressIdDomain(optional) ID of the address.
street(optional) ID of the address.
cityCode(optional) ID of the address.
city(optional) ID of the address.
stateCode(optional) ID of the address.
state(optional) ID of the address.
postalCode(optional) ID of the address.
countryCode(optional) ID of the address.
country(optional) ID of the address.

Example:

<ShipTo>
<!-- addressId and addressIdDomain -->
<Address addressID="1000467">
<!-- Name of the tenant -->
<Name xml:lang="en">Example Inc.</Name>
<PostalAddress>
<!-- name -->
<DeliverTo>Joe Average</DeliverTo>
<Street>123 Main Street</Street>
<City>Sunnyvale</City>
<!-- stateCode and state -->
<State isoStateCode="US-CA">CA</State>
<PostalCode>94089</PostalCode>
<!-- countryCode and country -->
<Country isoCountryCode="US">United States</Country>
</PostalAddress>
</Address>
</ShipTo>

Response

If everything goes well, you will receive a successful HTTP response with status 200 OK with a payload containing a URL that you can send to the user agent to follow.

{
"type": "cxml-punchout",
"punchout": {
"redirectUrl": "https://www.amazon.com/eprocurement/initiate-clean-punchout/123-4567890-1234567"
}
}

Following this URL will bring the end-user to the detail page of the product she was looking at on your frontend.

Errors

In case of an error, you can use the HTTP status code and the response body to find out what went wrong.

HTTP Status CodeDescription
400 Bad RequestThe server understood your request but is unable to complete it, e.g. because a required parameter is missing.
401 UnauthorizedYou sent invalid or expired credentials.
404 Not FoundThe product, catalog, or vendor wasn't found.
500 Internal Server ErrorSomething went wrong on our side.