Documentation
Feedback
Guides

[Deprecated] How to collect orders from sales channels

We have released a new method for integrating orders from external marketplaces, as a part of our Marketplace Protocol. If you used this previous method for integrating orders, you can still find their documentation in Order Logs and How to collect orders from sales channels. These previous methods, however, will not be maintained. If you are integrating orders for the first time, we recommend you use the instructions in our New Order Integration guide.

Orders in an integration fit into two different categories:

Paid orders: the marketplace only makes orders available for the integration once they are paid by the customer.

{"base64":"  ","img":{"width":5262,"height":1509,"type":"jpg","mime":"image/jpeg","wUnits":"px","hUnits":"px","length":183264,"url":"https://cdn.jsdelivr.net/gh/vtexdocs/dev-portal-content@main/images/deprecated-how-to-collect-orders-from-sales-channels-0.jpg"}}

Orders to be paid: the marketplace makes orders that have not been paid by the customer available for the integration.

{"base64":"  ","img":{"width":5262,"height":1325,"type":"jpg","mime":"image/jpeg","wUnits":"px","hUnits":"px","length":167947,"url":"https://cdn.jsdelivr.net/gh/vtexdocs/dev-portal-content@main/images/deprecated-how-to-collect-orders-from-sales-channels-1.jpg"}}
Right after the payment confirmation by the marketplace, the flow goes as the image below describes it:

{"base64":"  ","img":{"width":5262,"height":1481,"type":"jpg","mime":"image/jpeg","wUnits":"px","hUnits":"px","length":167558,"url":"https://cdn.jsdelivr.net/gh/vtexdocs/dev-portal-content@main/images/deprecated-how-to-collect-orders-from-sales-channels-2.jpg"}}

How orders reach the connector

A marketplace order can reach the connector by either a:

  1. Notification sent by the marketplace: when the marketplace informs the connector about the existence of an order, and the connector, after receiving the notification, goes to the marketplace to get order details.

{"base64":"  ","img":{"width":5262,"height":1476,"type":"jpg","mime":"image/jpeg","wUnits":"px","hUnits":"px","length":168930,"url":"https://cdn.jsdelivr.net/gh/vtexdocs/dev-portal-content@main/images/deprecated-how-to-collect-orders-from-sales-channels-3.jpg"}}

  1. Polling request made by the connector: when the connector checks the marketplace from time to time, to collect new orders.
    {"base64":"  ","img":{"width":5262,"height":1136,"type":"jpg","mime":"image/jpeg","wUnits":"px","hUnits":"px","length":140182,"url":"https://cdn.jsdelivr.net/gh/vtexdocs/dev-portal-content@main/images/deprecated-how-to-collect-orders-from-sales-channels-4.jpg"}}

Integrating orders

Follow the steps below, to integrate orders from external marketplaces:

  1. Collect order details from the endpoint provided by the marketplace.

  2. Create a request on the Place fulfillment order endpoint.

  3. Simulate fulfillment, to check if the SKU is available in VTEX.

  4. For each SKU retrieved, the connector must call the Get SKU and Context endpoint and:

    a. Validate if the SKU is active through the isActive property.

    b. Validate if the SKU is associated to the sales channel used in the integration through the salesChannel property.

  5. In case step 4 retrieves all SKUs that compose the order with their respective inventory levels and prices, the connector should insert the order through the Order Placement endpoint.

  1. In case step 5 returns success and creates the order within the VTEX platform, authorize the dispatch by the seller through the Authorize dispatch for fulfillment order endpoint.
  2. Check the Recommendations page to follow integration best practices.
  3. Check out the Order logs page to create appropriate error messages.

If all validations pass, the order is sent to VTEX and the operation is logged according to information described in the Order logs.

After VTEX OMS returns success, if the IDs between VTEX and the marketplace differ, the connector should store the mapping of the order (VTEX ID and Marketplace ID). This information will be used for order status update operations.

Be mindful to make all validations at once. In case there's an error detected, the connector presents the seller a list of actions to correct. This way we can avoid the correct - publish - correct cycle. If orders do not apply to the steps above, an error log must be filed.

API Reference

Use the endpoints described below to perform this step. It is important to note that when consuming this API, the connector must have a valid VTEX App Key and App Token. The diagram illustrates the endpoints used in the integration:

{"base64":"  ","img":{"width":5262,"height":3389,"type":"jpg","mime":"image/jpeg","wUnits":"px","hUnits":"px","length":460342,"url":"https://cdn.jsdelivr.net/gh/vtexdocs/dev-portal-content@main/images/deprecated-how-to-collect-orders-from-sales-channels-5.jpg"}}

All parameters in the endpoints below must be declared in the request. In case one of the parameters does not have a value, you must still send it as null.

Fulfillment simulation

Use the curl example below to perform the fulfillment Simulation.


_20
curl --location --request POST 'https://{{accountName}}.vtexcommercestable.com.br/api/checkout/pub/orderForms/simulation?affiliateId={{affiliateId}}={{salesChannelId}}' \
_20
--header 'Accept: application/vnd.vtex.checkout.debug.v1+json' \
_20
--header 'Content-Type: application/json' \
_20
--data-raw '{
_20
"items": [
_20
{
_20
"id": "13",
_20
"quantity": 1,
_20
"seller": "1"
_20
}
_20
],
_20
"marketingData": null,
_20
"postalCode": "04321-100",
_20
"country": "BRA",
_20
"selectedSla": null,
_20
"clientProfileData": null,
_20
"geoCoordinates": [],
_20
"isCheckedIn": false,
_20
"storeId": null
_20
}'

Shopping cart simulation

Use the request example below to perform the Shopping Cart Simulation. Check out our Shopping cart Simulation API Reference to know more details.


_35
{
_35
"items":[
_35
{...}
_35
]
_35
"ratesAndBenefitsData":{
_35
"rateAndBenefitsIdentifiers":[]
_35
"teaser":[]
_35
}
_35
"paymentData":{
_35
"installmentOptions":[...]
_35
"paymentSystems":[...]
_35
"payments":[]
_35
"giftCards":[]
_35
"giftCardMessages":[]
_35
"availableAccounts":[]
_35
"availableTokens":[]
_35
}
_35
"selectableGifts":[]
_35
"marketingData":NULL
_35
"postalCode":NULL
_35
"country":"BRA"
_35
"logisticsInfo":[
_35
{...}
_35
]
_35
"messages":[]
_35
"purchaseConditions":{
_35
"itemPurchaseConditions":[...]
_35
}
_35
"pickupPoints":[]
_35
"subscriptionData":NULL
_35
"totals":[
_35
{...}
_35
]
_35
"itemMetadata":NULL
_35
}

Place fulfillment order

Use the request example below to place fulfillment order. Check out our Place fulfillment order API Reference to know more details.


_93
[
_93
{
_93
"items": [
_93
{
_93
"id": "1",
_93
"price": 900,
_93
"quantity": 1,
_93
"seller": "1"
_93
}
_93
],
_93
"isCreatedAsync": true,
_93
"marketplaceOrderGroup" : "794901324",
_93
"marketplaceOrderId": "2630580124",
_93
"marketplacePaymentValue": 1100,
_93
"marketplacePaymentReferenceValue": 1100,
_93
"marketplaceServicesEndpoint": "http://skyhubintegration.vtexinternal.com/api/skyhubintegration/commercialcondition?an=grocery1",
_93
"clientProfileData": {
_93
"CorporateDocument": null, //Cnpj
_93
"CorporateName": null, //nome da empresa
_93
"CorporatePhone": null, // ddd+telefone
_93
"Document": "14310315771", //cpf
_93
"DocumentType": null, //se pessoa fisica, colocar CPF, senão CNPJ
_93
"Email": "conta@dominio.com.br",
_93
"FirstName": "Nome",
_93
"IsCorporate": false, //caso pessoa juridica o valor deve ser true
_93
"LastName": "Sobrenome",
_93
"Phone": "41998718616",
_93
"StateInscription": null, //inscrição estadual
_93
"TradeName": null,
_93
"UserProfileId": null //utilizado somente com pedidos VTEX
_93
},
_93
"shippingData": {
_93
"address": {
_93
"addressId": "Casa",
_93
"addressType": "Residencial",
_93
"receiverName": "Marcelo",
_93
"city": "Curitiba",
_93
"complement": null,
_93
"country": "BRA",
_93
"geoCoordinates": [],
_93
"neighborhood": "Novo Mundo",
_93
"number": "4000",
_93
"postalCode": "81020230",
_93
"reference": null,
_93
"state": "PR",
_93
"street": "Rua Eduardo Carlos Pereira"
_93
},
_93
"logisticsInfo": [
_93
{
_93
"itemIndex": 0,
_93
"price": 200,
_93
"selectedDeliveryChannel":"delivery",
_93
"selectedSla": null,
_93
"lockTTL": "1d", //tempo para reserva do estoque do pedido
_93
"shippingEstimate":"1d" //tempo de entrega do pedido
_93
}
_93
],
_93
"selectedAddresses":[
_93
{
_93
"addressType": "Residencial",
_93
"receiverName": "Henrique Vianna",
_93
"addressId": "2",
_93
"postalCode": "81020-235",
_93
"city": "Curitiba",
_93
"state": "PR",
_93
"country": "BRA",
_93
"street": "Rua Eduardo Carlos Pereira",
_93
"number": "4125",
_93
"neighborhood": "Portão",
_93
"complement": "",
_93
"reference": null,
_93
"geoCoordinates": [
_93
-49.2892059,
_93
-25.4826319
_93
]
_93
}],
_93
"isFob": false //se entrega feita pelo lojista coloque false, senão true
_93
},
_93
"customData": {
_93
"customApps": [{
_93
"fields": {
_93
"orderIdMarketplace": "2630580148",
_93
"paymentIdMarketplace": "8191598627"
_93
},
_93
"id": "marketplace-integration",
_93
"major": 1
_93
}]
_93
},
_93
"openTextField": {
_93
"value": "{\"Phones\":[\"21998718616\"]}"
_93
}
_93
}
_93
]

Authorize dispatch

Use the request example below to authorize dispatch. Check out our Authorize Dispatch API Reference to know more details.


_10
[
_10
{
_10
"marketplaceOrderId": "956"
_10
}
_10
]

Scenario 1: orders with price divergence in items between marketplace and VTEX

When to perform: after attempting to integrate an order in VTEX platform, the process returns an error FMT007 - signaling price divergence.

Connectors should:

  1. In case the call is successful (200 OK), signaling the creation of prive divergence rule, the order should be queued in VTEX.
  2. In case the call returns a bad request (400), signaling that the order could not be inserted for infringing price divergence rules, file an error log, following the error code x.
  3. In case the call returns an unauthorized request (500), signaling that the price divergence rule failed due to error in system communication, the order should be queued on the connector’s flow to perform a retry.

Scenario 2: inventory level divergence

When to perform: after attempting to integrate an order in VTEX platform, the process returns an error ORDER027 - signaling inventory error.

Connectors should:

  1. Generate an error log, according to the item x.
  2. Validate if the order status in the marketplace was altered to canceled. If so, generate the error log message x, and remove the order from the retry queue.
  3. If the order was not canceled, submit the order to be reprocessed.
  4. In case the call is successful (200 OK), signaling the creation of the order, connectors should log the operation according to x.
  5. In case the call returns a bad request (400), signaling that the order could not be inserted for infringing stock rules, file an error log, following the error code x.
  6. In case the call returns an server error (500), signaling that the order creation failed due to error in system communication, the order should be queued on the connector’s flow to perform a retry.

Scenario 3: SLA errors - no carriers to deliver the order

When to perform: after attempting to integrate an order in VTEX platform, the process returns an error ORDER027 - signaling that there are no carriers to attend that order.

Connectors should:

  1. Generate an error log, according to the item x.
  2. Validate if the order status in the marketplace was altered to canceled. If so, generate the error log message x, and remove the order from the retry queue.
  3. If the order was not canceled, submit the order to be reprocessed.
  4. In case the call is successful (200 OK), signaling the creation of the order, connectors should log the operation according to x.
  5. In case the call returns a bad request (400), signaling that the order could not be inserted for infringing carriers’ rules, file an error log, following the error code x.
  6. In case the call returns a server error (500), signaling that the order creation failed due to error in system communication, the order should be queued on the connector’s flow to perform a retry.

Scenario 4: SLA errors - no pickup points to attend the order

When to perform: after attempting to integrate an order in VTEX platform, the process returns an error ORDER027 - signaling that there are no pickup points for the end customer to retrieve their order.

Connectors should:

  1. Generate an error log, according to the item x.
  2. Validate if the order status in the marketplace was altered to canceled. If so, generate the error log message x, and remove the order from the retry queue.
  3. If the order was not canceled, submit the order to be reprocessed.
  4. In case the call is successful (200 OK), signaling the creation of the order, connectors should log the operation according to x.
  5. In case the call returns a bad request (400), signaling that the order could not be inserted for infringing pickup points’ rules, file an error log, following the error code x.
  6. In case the call returns an unauthorized request (500), signaling that the order creation failed due to error in system communication, the order should be queued on the connector’s flow to perform a retry.

Scenario 5: order is canceled by the marketplace

When to perform: when the order is canceled by the marketplace.

Connectors should:

  1. Verify if the order exists in the VTEX platform, by either: a. Checking the order ID relation between VTEX and the marketplace in their environment. b. Checking if the order exists through the Get Order endpoint.

  2. Validate the order status.

  3. If the order exists in VTEX, call the Cancel Order endpoint.

  4. If the order exists in VTEX, and the order status is invoiced, call the Order Invoice notification endpoint.

  5. In case the call is successful (200 OK), signaling the cancelling of the order, connectors should log the operation according to x.

  6. In case the call returns a bad request (400), signaling that the order could not be canceled, file an error log, following the error code x.

  7. In case the call returns an unauthorized request (500), signaling that the order cancelling failed due to error in system communication, the order should be queued on the connector’s flow to perform a retry.

Make sure that all steps are logged as either success or failure, to offer the operation’s full traceability. Check out the Order logs page to learn more.

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