Documentation
Feedback
Guides
API Reference

Guides
Guides

Creating a regular order with the Checkout API

Learn how to use VTEX APIs to efficiently handle the placement, payment, and delivery aspects of a regular order.

This step-by-step guide will walk you through the process of using the Checkout API and Payments Gateway API for handling the placement, payment, and delivery aspects of a regular order, with all responsibilities managed within the scope of a single account. It is divided into the following steps:

  1. Assess cart requirements: Begin by simulating a cart to assess available delivery and payment options. This step also involves checking whether the provided email address is already associated with an existing customer, which is required to place an order.
  2. Assemble the cart: Continue by building the cart, ensuring that all essential order details are properly structured according to the orderForm data structure.
  3. Handle the order: Place the order on the VTEX platform and send all required payment data to process the payment for the order.
  4. Process and validate the order: The process concludes with the processing of order details and a verification procedure to confirm the order's successful placement.

Before you begin

Before proceeding any further, ensure that you have a valid appKey and appToken with the necessary permissions to access the Checkout and Payments Gateway APIs. For more information, refer to the Roles article.

Click the steps below to navigate through this article and explore specific topics. Relevant code for each phase or parameter is highlighted on the right side of the screen.

Step 1 - Assessing cart requirements

In this step, we will verify that your store can fulfill the cart requirements and collect the essential order details necessary to ensure a smooth order placement process in the subsequent steps.

Simulating a cart

Use the Cart simulation endpoint to obtain the available delivery and payment options for the current cart configuration. In this request, you must provide the following information in the request body:

  • items.id: SKU ID.
  • items.quantity: The number of items in the cart.
  • items.seller: Seller's ID.
  • country: Three-letter ISO code of the country of the shipping address.
  • postalCode or geoCoordinates: Shipping address's postal code or geocoordinates.

Upon receiving a 200 OK response, the request will provide a response body containing all information about the cart. Take note of the following information, as it will be used in the following steps:

  • items
  • paymentData
  • logisticsInfo
Shell
Python
Node.js

_10
curl --request post \
_10
--url 'https://{accountName}.{environment}.com.br/api/checkout/pub/orderForms/simulation?RnbBehavior=0' \
_10
--header 'Accept: application/json' \
_10
--header 'Content-Type: application/json' \
_10
--header 'X-VTEX-API-AppKey: {appKey}' \
_10
--header 'X-VTEX-API-AppToken: {appToken}' \
_10
--data '{"items":[{"id":"1","quantity":1,"seller":"1"}],"country":"BRA","postalCode":"12345-000","geoCoordinates":[-47.924747467041016]}'

Response

_19
{
_19
"items": [],
_19
"ratesAndBenefitsData": {},
_19
"paymentData": {},
_19
"selectableGifts": [],
_19
"marketingData": {},
_19
"postalCode": string,
_19
"country": string,
_19
"logisticsInfo": [],
_19
"messages": [],
_19
"purchaseConditions": {},
_19
"pickupPoints": [],
_19
"subscriptionData": string,
_19
"totals": [],
_19
"itemMetadata": {},
_19
"sellers": [],
_19
"allowMultipleDeliveries": boolean,
_19
"minimumOrderValue": number
_19
}

Checking for existing customer

Send a request to the Get client by email endpoint to ensure a customer profile exists in your database associated with the email to be used in the order.

Upon receiving a 200 OK response, the request will provide a response body containing all information about the customer profile. Take note of the following information, as it will be used in the following steps:

  • availableAddresses
  • userProfile

If the response body fields are empty in this request, it may indicate that no customer is registered under this email, or that the customer profile is invalid or incomplete. In this case, you can use a different email address or enter data for a new customer when assembling the cart.

Shell
Python
Node.js

_10
curl --request get \
_10
--url 'https://{accountName}.{environment}.com.br/api/checkout/pub/profiles?email={emailAddress}' \
_10
--header 'Accept: application/json' \
_10
--header 'Content-Type: application/json' \
_10
--header 'X-VTEX-API-AppKey: {appKey}' \
_10
--header 'X-VTEX-API-AppToken: {appToken}'

Response

_44
{
_44
"userProfileId": string,
_44
"profileProvider": string,
_44
"availableAccounts": [],
_44
"availableAddresses": [
_44
{
_44
"addressType": string,
_44
"receiverName": string,
_44
"addressId": string,
_44
"isDisposable": boolean,
_44
"postalCode": string,
_44
"city": string,
_44
"state": string,
_44
"country": string,
_44
"street": string,
_44
"number": string,
_44
"neighborhood": string,
_44
"complement": null,
_44
"reference": null,
_44
"geoCoordinates": []
_44
}
_44
],
_44
"contactInformation": [],
_44
"contacts": [],
_44
"contactsInfo": [],
_44
"userProfile": {
_44
"email": string,
_44
"firstName": string,
_44
"lastName": string,
_44
"document": string,
_44
"documentType": string,
_44
"phone": string,
_44
"corporateName": null,
_44
"tradeName": null,
_44
"corporateDocument": null,
_44
"stateInscription": null,
_44
"corporatePhone": null,
_44
"isCorporate": boolean,
_44
"profileCompleteOnLoading": null,
_44
"profileErrorOnLoading": null,
_44
"customerClass": null
_44
},
_44
"isComplete": boolean
_44
}

Step 2 - Assembling the cart

In this step, we will arrange the order details into the specified data format, following the orderForm data structure. This formatted cart data will be used as the request body in the following steps.

Below, we will briefly examine the key elements that make up the orderForm, which include:

  • items
  • clientProfileData
  • shippingData.address
  • shippingData.logisticsInfo
  • paymentData

While an orderForm may include various elements, a standard order generally comprises the key components described above.

orderForm.json

_32
{
_32
"allowManualPrice": boolean,
_32
"canEditData": boolean,
_32
"clientPreferencesData": {},
_32
"clientProfileData": {},
_32
"commercialConditionData": {},
_32
"customData": {},
_32
"giftRegistryData": {},
_32
"hooksData": {},
_32
"ignoreProfileData": boolean,
_32
"isCheckedIn": boolean,
_32
"itemMetadata": {},
_32
"items": {},
_32
"itemsOrdination": {},
_32
"loggedIn": boolean,
_32
"marketingData": {},
_32
"messages": [],
_32
"openTextField": {},
_32
"orderFormId": string,
_32
"paymentData": {},
_32
"ratesAndBenefitsData": {},
_32
"salesChannel": "1",
_32
"selectableGifts": {},
_32
"sellers": {},
_32
"shippingData": {},
_32
"storeId": {},
_32
"storePreferencesData": {},
_32
"totalizers": {},
_32
"userProfileId": {},
_32
"userType": {},
_32
"value": number
_32
}

items

items is an array that contains all data pertinent to the SKUs being purchased. Build the items array using the items array obtained from the Simulating a cart step. For more complex examples, see the Place order API reference.

orderForm.json

_16
{
_16
"items": [
_16
{
_16
"id": "1",
_16
"quantity": 1,
_16
"seller": "1",
_16
"price": 10000
_16
}
_16
],
_16
"clientProfileData": {},
_16
"shippingData": {
_16
"address": {},
_16
"logisticsInfo": []
_16
},
_16
"paymentData": {}
_16
}

clientProfileData: New customers

clientProfileData is an object that contains information about the customer. If you noted the customer does not exist in your database during the Checking for existing customer step, build the clientProfileData object with the data of the new customer willing to place the order.

orderForm.json

_22
{
_22
"items": [],
_22
"clientProfileData": {
_22
"email": "email@domain.com",
_22
"firstName": "First name",
_22
"lastName": "Last name",
_22
"document": "078051120",
_22
"documentType": "ssn",
_22
"phone": "1234567890",
_22
"corporateName": null,
_22
"tradeName": null,
_22
"corporateDocument": null,
_22
"stateInscription": null,
_22
"corporatePhone": null,
_22
"isCorporate": false
_22
},
_22
"shippingData": {
_22
"address": {},
_22
"logisticsInfo": []
_22
},
_22
"paymentData": {}
_22
}

clientProfileData: Existing customers

If the customer already exists in your database, use the userProfile.email obtained in the Checking for existing customer step to build the clientProfileData object. The email address is enough to register the order to the shopper’s existing account.

orderForm.json

_11
{
_11
"items": [],
_11
"clientProfileData": {
_11
"email": "email@domain.com"
_11
},
_11
"shippingData": {
_11
"address": {},
_11
"logisticsInfo": []
_11
},
_11
"paymentData": {}
_11
}

shippingData.address: New customers

shippingData.address is an object that contains information about the shipping address. If you noted the customer does not exist in your database during the Checking for existing customer step, build the shippingData.address object with the data of the new customer willing to place the order.

orderForm.json

_21
{
_21
"items": [],
_21
"clientProfileData": {},
_21
"shippingData": {
_21
"address": {
_21
"addressType": "residential",
_21
"receiverName": "Testing VTEX",
_21
"postalCode": "33301",
_21
"city": "Fort Lauderdale",
_21
"state": "FL",
_21
"country": "USA",
_21
"street": "110 East Broward Blvd",
_21
"number": null,
_21
"neighborhood": null,
_21
"complement": "Suite 1700",
_21
"reference": null,
_21
"geoCoordinates": []
_21
}
_21
},
_21
"paymentData": {}
_21
}

shippingData.address: Existing customers

If the customer already exists in your database, use the desired availableAddresses[i].addressId obtained from the Checking for existing customer step to build the shippingData.address block.

orderForm.json

_10
{
_10
"items": [],
_10
"clientProfileData": {},
_10
"shippingAddress": {
_10
"address": {
_10
"addressId": "666c2e830bd9474ab6f6cc53fb6dd2d2"
_10
}
_10
},
_10
"paymentData": {}
_10
}

shippingData.logisticsInfo

logisticsInfo is an array that contains logistics information, such as the desired delivery option and freight cost for each item in the items array.

  • Create the logisticsInfo array with the same number of objects as in the items array. For each object within the logisticsInfo array, define the following elements:

    • itemIndex - index of the corresponding item in the items array. For example, the object referring to the first item in the items array has an itemIndex of 0.
    • selectedSla - desired delivery option. You can find the id value of the available options in the slas array obtained from the Simulating a cart step.
    • price - price of the item. You can retrieve this value from the Simulating a cart step.
    • (Optional) If the delivery method is pickup point, add the information "selectedDeliveryChannel": "pickup-in-point".
orderForm.json

_16
{
_16
"items": [],
_16
"clientProfileData": {},
_16
"shippingData": {
_16
"address": {},
_16
"logisticsInfo": [
_16
{
_16
"itemIndex": 0,
_16
"selectedSla": "Regular",
_16
"price": 100,
_16
"selectedDeliveryChannel": "pickup-in-point"
_16
}
_16
]
_16
},
_16
"paymentData": {}
_16
}

paymentData.payments

paymentData.payments is an array that contains information regarding the chosen payment method and installment preferences for the order. Build the paymentData.payments array considering the response obtained from the Simulating a cart step. For each payment option, define the following elements:

  • paymentSystem - ID of the desired payment system.
  • referenceValue - reference value used to calculate interest rates. If no interest applies to the order, the value and referenceValue should be the same.
  • value - total amount to be paid by the shopper.
  • installments - number of installments.

For more complex examples, see the Place order API reference.

orderForm.json

_18
{
_18
"items": [],
_18
"clientProfileData": {},
_18
"shippingData": {
_18
"address": {},
_18
"logisticsInfo": []
_18
},
_18
"paymentData": {
_18
"payments": [
_18
{
_18
"paymentSystem": "1",
_18
"referenceValue": 10100,
_18
"value": 10100,
_18
"installments": 1
_18
}
_18
]
_18
}
_18
}

Step 3 - Handling the order

Before creating the new order, it is necessary to verify that the orderForm created in the previous steps has the appropriate structure in a valid JSON format.

New customer orderForm

If the orderForm was created for a new customer (not yet registered in the store's database), it should follow this structure.

orderForm.json

_57
{
_57
"items": [
_57
{
_57
"id": "1",
_57
"quantity": 1,
_57
"seller": "1",
_57
"price": 10000
_57
}
_57
],
_57
"clientProfileData": {
_57
"email": "email@domain.com",
_57
"firstName": "Testing",
_57
"lastName": "VTEX",
_57
"document": "078051120",
_57
"documentType": "ssn",
_57
"phone": "1234567890",
_57
"corporateName": null,
_57
"tradeName": null,
_57
"corporateDocument": null,
_57
"stateInscription": null,
_57
"corporatePhone": null,
_57
"isCorporate": false
_57
},
_57
"shippingData": {
_57
"address": {
_57
"addressType": "residential",
_57
"receiverName": "Testing VTEX",
_57
"postalCode": "33301",
_57
"city": "Fort Lauderdale",
_57
"state": "FL",
_57
"country": "USA",
_57
"street": "110 East Broward Blvd",
_57
"number": null,
_57
"neighborhood": null,
_57
"complement": "Suite 1700",
_57
"reference": null,
_57
"geoCoordinates": []
_57
},
_57
"logisticsInfo": [
_57
{
_57
"itemIndex": 0,
_57
"selectedSla": "Regular",
_57
"price": 100
_57
}
_57
]
_57
},
_57
"paymentData": {
_57
"payments": [
_57
{
_57
"paymentSystem": "1",
_57
"referenceValue": 10100,
_57
"value": 10100,
_57
"installments": 1
_57
}
_57
]
_57
}
_57
}

Existing customer orderForm

If the orderForm was created for an existing customer who already has a customer profile registered in the store's database, it should follow this structure.

orderForm.json

_35
{
_35
"items": [
_35
{
_35
"id": "1",
_35
"quantity": 1,
_35
"seller": "1",
_35
"price": 10000
_35
}
_35
],
_35
"clientProfileData": {
_35
"email": "email@domain.com"
_35
},
_35
"shippingData": {
_35
"address": {
_35
"addressId": "666c2e830bd9474ab6f6cc53fb6dd2d2"
_35
},
_35
"logisticsInfo": [
_35
{
_35
"itemIndex": 0,
_35
"selectedSla": "Regular",
_35
"price": 100
_35
}
_35
]
_35
},
_35
"paymentData": {
_35
"payments": [
_35
{
_35
"paymentSystem": "1",
_35
"referenceValue": 10100,
_35
"value": 10100,
_35
"installments": 1
_35
}
_35
]
_35
}
_35
}

Placing the order

Place a new order via the Place order endpoint using the orderForm you built as the request body.

Upon receiving a 201 Created response, take note of these five pieces of information:

  • transactionId - ID of the transaction, which can be found within an object contained in the merchantTransactions array.
  • orderId - ID of the order within VTEX’s Order Management System (OMS). You can find the orderId within each object in the orders array.
  • orderGroup - ID that groups all orders related to the same purchase. For example, when an order is fulfilled by multiple sellers, each seller has its own order ID (v71021570str-01 and v71021570str-02), but they share the same order group ID (v71021570str).
  • addressId - ID of the customer address. If you plan to use the same address for both shipping and billing, get the addressId from the orders[].shippingData.address object.
  • Vtex_CHKO_Auth - authentication cookie provided in the response.

If you are using an email from an existing customer, ensure that the corresponding customer account is logged into your store. Otherwise, the process will fail.

Shell
Python
Node.js

_10
curl --request put \
_10
--url 'https://{accountName}.{environment}.com.br/api/checkout/pub/orders' \
_10
--header 'Accept: application/json' \
_10
--header 'Content-Type: application/json' \
_10
--header 'X-VTEX-API-AppKey: {appKey}' \
_10
--header 'X-VTEX-API-AppToken: {appToken}' \
_10
--data '{orderForm}'

Response

_71
{
_71
"orderForm": null,
_71
"transactionData": {
_71
"merchantTransactions": [
_71
{
_71
"id": string,
_71
"transactionId": string,
_71
"merchantName": string,
_71
"payments": [],
_71
"transactionId": string,
_71
}
_71
],
_71
"receiverUri": string,
_71
"gatewayCallbackTemplatePath": string
_71
},
_71
"orders": [
_71
{
_71
"orderId": string,
_71
"orderGroup": string,
_71
"state": null,
_71
"isCheckedIn": boolean,
_71
"sellerOrderId": string,
_71
"storeId": null,
_71
"checkedInPickupPointId": null,
_71
"value": number,
_71
"items": [],
_71
"sellers": [],
_71
"totals": [],
_71
"clientProfileData": {},
_71
"ratesAndBenefitsData": {},
_71
"shippingData": {
_71
"address": {
_71
"addressId": string
_71
}
_71
},
_71
"paymentData": {},
_71
"clientPreferencesData": null,
_71
"commercialConditionData": null,
_71
"giftRegistryData": null,
_71
"marketingData": null,
_71
"storePreferencesData": {},
_71
"openTextField": {},
_71
"invoiceData": null,
_71
"itemMetadata": {},
_71
"taxData": null,
_71
"customData": null,
_71
"hooksData": null,
_71
"changeData": null,
_71
"subscriptionData": null,
_71
"merchantContextData": null,
_71
"salesChannel": string,
_71
"followUpEmail": string,
_71
"creationDate": string,
_71
"lastChange": string,
_71
"timeZoneCreationDate": string,
_71
"timeZoneLastChange": string,
_71
"isCompleted": boolean,
_71
"hostName": string,
_71
"merchantName": null,
_71
"userType": string,
_71
"roundingError": number,
_71
"allowEdition": boolean,
_71
"allowCancellation": boolean,
_71
"isUserDataVisible": boolean,
_71
"allowChangeSeller": boolean,
_71
"orderFormCreationDate": string,
_71
"budgetData": null
_71
}
_71
],
_71
"allowMultipleDeliveries": boolean
_71
}

Resolving the order payment

Now, we will communicate the necessary payment data to VTEX to finalize the order payment.

Starting from the moment the order is placed, you have 5 minutes to submit the payment information and process the order (Step 4). If the payment information and order are not submitted and processed within 5 minutes, the order will be automatically canceled.

  • Send a request to the Send payments information endpoint, considering the following:

    • Use the transactionId value from the previous step as both the path parameter and the value for the id field within the transaction object.
    • Set the merchantName field within the transaction object to your account name.
    • Use the orderId value from the previous step as a query string parameter.
    • Ensure that the request body is based on the paymentData section of your orderForm.
    • In the fields object, you can:
      • Fill in the credit or debit card information (when applicable).
      • Use the addressId field to reference an existing address, or provide a new address object for an entirely new address. This type of information is only required if the shopper's address was not previously entered during checkout.

This request does not return any data in the response body, only a 201 Created success confirmation message.

Shell
Python
Node.js

_10
curl --request post \
_10
--url 'https://{accountName}.vtexpayments.com.br/api/pub/transactions/{transactionId}/payments?orderId={orderId}' \
_10
--header 'Accept: application/json' \
_10
--header 'Content-Type: application/json' \
_10
--header 'X-VTEX-API-AppKey: {appKey}' \
_10
--header 'X-VTEX-API-AppToken: {appToken}' \
_10
--data '[{"paymentSystem":4,"installments":1,"currencyCode":"BRL","value":100,"installmentsInterestRate":0,"installmentsValue":100,"referenceValue":100,"fields":{"holderName":"UserTest","cardNumber":"5378244888889174","validationCode":"231","dueDate":"10/19","document":"8041734561","accountId":"","address":null,"callbackUrl":""},"transaction":{"id":"{{transactionId}}","merchantName":"{{accountName}}"}}]'

Response

_10
201 Created

Step 4 - Processing and validating the order

In this final step, we will process the order.

  • Send a request to the Process order endpoint, using the orderGroup value as a path parameter.

If the payment is processed without any issues, the order should be successfully placed (204 No Content status). Otherwise, a 500 Internal Server Error message might occur.

Note that this process uses the gateway connectors configured in your VTEX environment. Be careful to prevent any unwanted charges or unexpected payment denials.

Shell
Python
Node.js

_10
curl --request post \
_10
--url 'https://{accountName}.{environment}.com.br/api/checkout/pub/gatewayCallback/{orderGroup}' \
_10
--header 'Accept: application/json' \
_10
--header 'Content-Type: application/json' \
_10
--header 'Cookie: {cookie}' \
_10
--header 'X-VTEX-API-AppKey: {appKey}' \
_10
--header 'X-VTEX-API-AppToken: {appToken}'

Response

_10
204 No Content

Verifying the order placement

Finally, you can confirm if your order was correctly placed by checking the Order management in VTEX Admin. Alternatively, you can use the Get order and List orders endpoints for this purpose.

Shell
Python
Node.js

_10
curl --request get \
_10
--url 'https://{accountName}.vtexcommercestable.com.br/api/oms/pvt/orders/{orderId}' \
_10
--header 'Accept: application/json' \
_10
--header 'Content-Type: application/json' \
_10
--header 'X-VTEX-API-AppKey: {appKey}' \
_10
--header 'X-VTEX-API-AppToken: {appToken}'

Response

_62
{
_62
"orderId": string,
_62
"sequence": string,
_62
"marketplaceOrderId": string,
_62
"marketplaceServicesEndpoint": string,
_62
"sellerOrderId": string,
_62
"origin": enum,
_62
"affiliateId": string,
_62
"salesChannel": string,
_62
"merchantName": string,
_62
"status": string,
_62
"workflowIsInError": boolean,
_62
"statusDescription": string,
_62
"value": integer,
_62
"creationDate": string,
_62
"lastChange": string,
_62
"orderGroup": string,
_62
"followUpEmail": string,
_62
"lastMessage": string,
_62
"hostname": string,
_62
"isCompleted": boolean,
_62
"roundingError": integer,
_62
"orderFormId": string,
_62
"allowCancellation": boolean,
_62
"allowEdition": boolean,
_62
"isCheckedIn": boolean,
_62
"authorizedDate": string,
_62
"invoicedDate": string,
_62
"cancelReason": string,
_62
"checkedInPickupPointId": string,
_62
"totals": [],
_62
"sellers": [],
_62
"clientPreferencesData": [],
_62
"cancellationData": [],
_62
"taxData": [],
_62
"subscriptionData": [],
_62
"itemMetadata": {},
_62
"marketplace": {},
_62
"storePreferencesData": {},
_62
"customData": {},
_62
"commercialConditionData": string,
_62
"openTextField": {},
_62
"invoiceData": {},
_62
"changesAttachment": {},
_62
"callCenterOperatorData": {},
_62
"packageAttachment": {},
_62
"paymentData": {},
_62
"shippingData": {},
_62
"ratesAndBenefitsData": {},
_62
"marketingData": null,
_62
"giftRegistryData": null,
_62
"clientProfileData": {},
_62
"items": [],
_62
"marketplaceItems": [],
_62
"cancellationRequests": null,
_62
"approvedBy": null,
_62
"cancelledBy": null,
_62
"purchaseAgentData": null,
_62
"pendingData": null,
_62
"creationEnvironment": "STABLE",
_62
"authorizationPolicyData": null
_62
}

Step 1 - Assessing cart requirements

In this step, we will verify that your store can fulfill the cart requirements and collect the essential order details necessary to ensure a smooth order placement process in the subsequent steps.

Simulating a cart

Use the Cart simulation endpoint to obtain the available delivery and payment options for the current cart configuration. In this request, you must provide the following information in the request body:

  • items.id: SKU ID.
  • items.quantity: The number of items in the cart.
  • items.seller: Seller's ID.
  • country: Three-letter ISO code of the country of the shipping address.
  • postalCode or geoCoordinates: Shipping address's postal code or geocoordinates.

Upon receiving a 200 OK response, the request will provide a response body containing all information about the cart. Take note of the following information, as it will be used in the following steps:

  • items
  • paymentData
  • logisticsInfo

Checking for existing customer

Send a request to the Get client by email endpoint to ensure a customer profile exists in your database associated with the email to be used in the order.

Upon receiving a 200 OK response, the request will provide a response body containing all information about the customer profile. Take note of the following information, as it will be used in the following steps:

  • availableAddresses
  • userProfile

If the response body fields are empty in this request, it may indicate that no customer is registered under this email, or that the customer profile is invalid or incomplete. In this case, you can use a different email address or enter data for a new customer when assembling the cart.

Step 2 - Assembling the cart

In this step, we will arrange the order details into the specified data format, following the orderForm data structure. This formatted cart data will be used as the request body in the following steps.

Below, we will briefly examine the key elements that make up the orderForm, which include:

  • items
  • clientProfileData
  • shippingData.address
  • shippingData.logisticsInfo
  • paymentData

While an orderForm may include various elements, a standard order generally comprises the key components described above.

items

items is an array that contains all data pertinent to the SKUs being purchased. Build the items array using the items array obtained from the Simulating a cart step. For more complex examples, see the Place order API reference.

clientProfileData: New customers

clientProfileData is an object that contains information about the customer. If you noted the customer does not exist in your database during the Checking for existing customer step, build the clientProfileData object with the data of the new customer willing to place the order.

clientProfileData: Existing customers

If the customer already exists in your database, use the userProfile.email obtained in the Checking for existing customer step to build the clientProfileData object. The email address is enough to register the order to the shopper’s existing account.

shippingData.address: New customers

shippingData.address is an object that contains information about the shipping address. If you noted the customer does not exist in your database during the Checking for existing customer step, build the shippingData.address object with the data of the new customer willing to place the order.

shippingData.address: Existing customers

If the customer already exists in your database, use the desired availableAddresses[i].addressId obtained from the Checking for existing customer step to build the shippingData.address block.

shippingData.logisticsInfo

logisticsInfo is an array that contains logistics information, such as the desired delivery option and freight cost for each item in the items array.

  • Create the logisticsInfo array with the same number of objects as in the items array. For each object within the logisticsInfo array, define the following elements:

    • itemIndex - index of the corresponding item in the items array. For example, the object referring to the first item in the items array has an itemIndex of 0.
    • selectedSla - desired delivery option. You can find the id value of the available options in the slas array obtained from the Simulating a cart step.
    • price - price of the item. You can retrieve this value from the Simulating a cart step.
    • (Optional) If the delivery method is pickup point, add the information "selectedDeliveryChannel": "pickup-in-point".

paymentData.payments

paymentData.payments is an array that contains information regarding the chosen payment method and installment preferences for the order. Build the paymentData.payments array considering the response obtained from the Simulating a cart step. For each payment option, define the following elements:

  • paymentSystem - ID of the desired payment system.
  • referenceValue - reference value used to calculate interest rates. If no interest applies to the order, the value and referenceValue should be the same.
  • value - total amount to be paid by the shopper.
  • installments - number of installments.

For more complex examples, see the Place order API reference.

Step 3 - Handling the order

Before creating the new order, it is necessary to verify that the orderForm created in the previous steps has the appropriate structure in a valid JSON format.

New customer orderForm

If the orderForm was created for a new customer (not yet registered in the store's database), it should follow this structure.

Existing customer orderForm

If the orderForm was created for an existing customer who already has a customer profile registered in the store's database, it should follow this structure.

Placing the order

Place a new order via the Place order endpoint using the orderForm you built as the request body.

Upon receiving a 201 Created response, take note of these five pieces of information:

  • transactionId - ID of the transaction, which can be found within an object contained in the merchantTransactions array.
  • orderId - ID of the order within VTEX’s Order Management System (OMS). You can find the orderId within each object in the orders array.
  • orderGroup - ID that groups all orders related to the same purchase. For example, when an order is fulfilled by multiple sellers, each seller has its own order ID (v71021570str-01 and v71021570str-02), but they share the same order group ID (v71021570str).
  • addressId - ID of the customer address. If you plan to use the same address for both shipping and billing, get the addressId from the orders[].shippingData.address object.
  • Vtex_CHKO_Auth - authentication cookie provided in the response.

If you are using an email from an existing customer, ensure that the corresponding customer account is logged into your store. Otherwise, the process will fail.

Resolving the order payment

Now, we will communicate the necessary payment data to VTEX to finalize the order payment.

Starting from the moment the order is placed, you have 5 minutes to submit the payment information and process the order (Step 4). If the payment information and order are not submitted and processed within 5 minutes, the order will be automatically canceled.

  • Send a request to the Send payments information endpoint, considering the following:

    • Use the transactionId value from the previous step as both the path parameter and the value for the id field within the transaction object.
    • Set the merchantName field within the transaction object to your account name.
    • Use the orderId value from the previous step as a query string parameter.
    • Ensure that the request body is based on the paymentData section of your orderForm.
    • In the fields object, you can:
      • Fill in the credit or debit card information (when applicable).
      • Use the addressId field to reference an existing address, or provide a new address object for an entirely new address. This type of information is only required if the shopper's address was not previously entered during checkout.

This request does not return any data in the response body, only a 201 Created success confirmation message.

Step 4 - Processing and validating the order

In this final step, we will process the order.

  • Send a request to the Process order endpoint, using the orderGroup value as a path parameter.

If the payment is processed without any issues, the order should be successfully placed (204 No Content status). Otherwise, a 500 Internal Server Error message might occur.

Note that this process uses the gateway connectors configured in your VTEX environment. Be careful to prevent any unwanted charges or unexpected payment denials.

Verifying the order placement

Finally, you can confirm if your order was correctly placed by checking the Order management in VTEX Admin. Alternatively, you can use the Get order and List orders endpoints for this purpose.

Shell
Python
Node.js

_10
curl --request post \
_10
--url 'https://{accountName}.{environment}.com.br/api/checkout/pub/orderForms/simulation?RnbBehavior=0' \
_10
--header 'Accept: application/json' \
_10
--header 'Content-Type: application/json' \
_10
--header 'X-VTEX-API-AppKey: {appKey}' \
_10
--header 'X-VTEX-API-AppToken: {appToken}' \
_10
--data '{"items":[{"id":"1","quantity":1,"seller":"1"}],"country":"BRA","postalCode":"12345-000","geoCoordinates":[-47.924747467041016]}'

Response

_19
{
_19
"items": [],
_19
"ratesAndBenefitsData": {},
_19
"paymentData": {},
_19
"selectableGifts": [],
_19
"marketingData": {},
_19
"postalCode": string,
_19
"country": string,
_19
"logisticsInfo": [],
_19
"messages": [],
_19
"purchaseConditions": {},
_19
"pickupPoints": [],
_19
"subscriptionData": string,
_19
"totals": [],
_19
"itemMetadata": {},
_19
"sellers": [],
_19
"allowMultipleDeliveries": boolean,
_19
"minimumOrderValue": number
_19
}

Contributors
2
Photo of the contributor
Photo of the contributor
Was this helpful?
Yes
No
Suggest Edits (GitHub)
Was this helpful?
Yes
No
Suggest Edits (GitHub)
On this page