Documentation
Feedback
Guides
API Reference

Guides
CheckoutOrder Placement
Create a regular order from an existing cart

The shopping cart is where the information of the products chosen by the customer while browsing a store is gathered. This data may include item prices, shipping value, payment, and delivery methods, among others.

This guide will describe how to create an order from an existing shopping cart by the API.

To place an order from a new cart, access the Create a regular order using the Checkout API.

Try the interactive version of this article by accessing this link. Code will be highlighted and focused for your convenience.

Getting shopping cart information

The first step is to get the orderFormId of the shopping cart you want to create an order. For more information, access the Get cart information by ID guide.

Placing order from an existing cart

To create an order via a specific shopping cart, you need to use the Place order from an existing cart endpoint. In this request, you must send the orderFormId through the URL address, as shown by the example below:

https://{accountName}.{environment.com.br}/api/checkout/pub/orderForm/ede846222cd44046ba6c638442c3505a/transaction

Additionally, you need to send the request body containing the following information:

  • referenceId: ID of the orderForm corresponding to the cart in which the order will be created (orderFormId).
  • savePersonalData: this parameter should be set as "true" if the shopper’s data provided during checkout should be saved for future reference. Default value is "false".
  • optinNewsLetter: this parameter should be set as "true" if the shopper opted to receive the newsletter. Default value is "false".
  • value: total value of the order without separating cents. For example, $24.99 is represented by 2499.
  • referenceValue: reference value of the order for calculating interest (if applicable). It can be equal to the total value and does not separate cents. For example, $24.99 is represented by 2499.
  • interestValue: interest rate to be used in case it applies.

See a request body example below:


_10
{
_10
"referenceId": "ede846222cd44046ba6c638442c3505a",
_10
"savePersonalData": false,
_10
"optinNewsLetter": false,
_10
"value": 3500,
_10
"referenceValue":3500,
_10
"interestValue": 0
_10
}

After sending the request, the endpoint will return the response body containing all information of a regular order. The example below shows only some of the data returned in this request.


_109
{
_109
"id": null,
_109
"merchantTransactions": [],
_109
"receiverUri": null,
_109
"gatewayCallbackTemplatePath": null,
_109
"orderGroup": null,
_109
"orderFormId": "ec00bf808e9f474ea8476681ba37ee2e",
_109
"salesChannel": "1",
_109
"loggedIn": true,
_109
"isCheckedIn": false,
_109
"storeId": null,
_109
"checkedInPickupPointId": null,
_109
"allowManualPrice": true,
_109
"canEditData": true,
_109
"userProfileId": "b2632321b-43326-4893-bfe3-bd922dsgdf4af",
_109
"userType": null,
_109
"ignoreProfileData": false,
_109
"value": 310,
_109
"messages": [ ],
_109
"items": [
_109
{
_109
"uniqueId": "CG5652A26705E4026B30E343FF061E26",
_109
"id": "29",
_109
"productId": "18",
_109
"productRefId": null,
_109
"refId": "456",
_109
"ean": null,
_109
"name": "Real coin",
_109
"skuName": "Real coin",
_109
"modalType": null,
_109
"parentItemIndex": null,
_109
"parentAssemblyBinding": null,
_109
"assemblies": [],
_109
"priceValidUntil": "2024-02-06T19:41:02Z",
_109
"tax": 0,
_109
"taxCode":"54WC8ZN6K8",
_109
"price": 100,
_109
"listPrice": 100,
_109
"manualPrice": null,
_109
"manualPriceAppliedBy": null,
_109
"sellingPrice": 100,
_109
"rewardValue": 0,
_109
"isGift": false,
_109
"additionalInfo": {
_109
"dimension": null,
_109
"brandName": "Brand name",
_109
"brandId": "2000000",
_109
"offeringInfo": null,
_109
"offeringType": null,
_109
"offeringTypeId": null
_109
},
_109
"preSaleDate": null,
_109
"productCategoryIds": "/1/",
_109
"productCategories": {
_109
"1": "Category"
_109
},
_109
"quantity": 2,
_109
"seller": "1",
_109
"sellerChain": [
_109
"1"
_109
],
_109
...
_109
"shippingData": {
_109
"address": {
_109
"addressType": "residential",
_109
"receiverName": "R S",
_109
"addressId": "5431864143",
_109
"isDisposable": true,
_109
"postalCode": "12200-000",
_109
"city": "São Paulo",
_109
"state": "SP",
_109
"country": "BRA",
_109
"street": "Rua Teste",
_109
"number": "0",
_109
"neighborhood": "Conjunto Residencial Teste",
_109
"complement": null,
_109
"reference": null,
_109
"geoCoordinates": [
_109
-45.00000000000000,
_109
-23.00000000000
_109
]
_109
},
_109
"logisticsInfo": [
_109
{
_109
"itemIndex": 0,
_109
"selectedSla": "Normal",
_109
"selectedDeliveryChannel": "delivery",
_109
"addressId": "5431864143",
_109
"slas": [
_109
{
_109
"id": "Normal",
_109
"deliveryChannel": "delivery",
_109
"name": "Normal",
_109
"deliveryIds": [
_109
{
_109
"courierId": "1",
_109
"warehouseId": "1_1",
_109
"dockId": "1",
_109
"courierName": "Transportadora",
_109
"quantity": 2,
_109
"kitItemDetails": []
_109
}
_109
],
_109
"shippingEstimate": "3bd",
_109
"shippingEstimateDate": null,
_109
"lockTTL": null,
_109
"availableDeliveryWindows": [],
_109
"deliveryWindow": null,
_109
...

For more information about the meaning of each of the fields available in the shopping cart, access the orderForm guide.

After creating an order using this procedure, you have 5 (five) minutes to send payment information and then request order processing. Otherwise, the order is automatically canceled and tagged incomplete.

Error codes

The following errors may appear as a message in the response body.

400 - Bad Request

  • Message error example (code ORD002): "Invalid order form": the orderFormId information is not valid.

_10
{
_10
"fields": {},
_10
"error": {
_10
"code": "ORD002",
_10
"message": "Invalid order form",
_10
"exception": null
_10
},
_10
"operationId": "f01ef909-8b81-4ffd-a91d-82be680d60ff"
_10
}

  • Message error example (code CHK0016): "Payment value does not match with reference value": the fields value and referenceValue have different values even without the use of interest in the payment. Modify the values used or check if the interest rate is applicable to this order.

_10
{
_10
"fields": {},
_10
"error": {
_10
"code": "CHK0016",
_10
"message": "Payment value does not match with reference value",
_10
"exception": null
_10
},
_10
"operationId": "6a080d5f-6911-4469-a661-312e93c23419"
_10
}

404 - Not Found

  • Message error example: "The requested URL was not found on the server": check that the URL data is correct.

_10
<body>
_10
<h1>404 Not Found</h1>
_10
<p>The requested URL was not found on this server.</p>
_10
</body>

500 - Internal Server Error

  • Message error example (code ORD005): "The purchase cannot be done without items": this message will appear when the shopping cart (orderFormId) informed in the request does not have any item, making it impossible to create an order.

_10
{
_10
"fields": {},
_10
"error": {
_10
"code": "ORD005",
_10
"message": "The purchase cannot be done without items",
_10
"exception": null
_10
},
_10
"operationId": "673771c0-f5ba-4fa6-800d-bea836c51f93"
_10
}

Contributors
4
Photo of the contributor
Photo of the contributor
Photo of the contributor
Photo of the contributor
+ 4 contributors
Was this helpful?
Yes
No
Suggest edits (Github)
Contributors
4
Photo of the contributor
Photo of the contributor
Photo of the contributor
Photo of the contributor
+ 4 contributors
On this page