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.
Orders to be paid: the marketplace makes orders that have not been paid by the customer available for the integration.
How orders reach the connector
A marketplace order can reach the connector by either a:
- 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.
- Polling request made by the connector: when the connector checks the marketplace from time to time, to collect new orders.
Integrating orders
Follow the steps below, to integrate orders from external marketplaces:
-
Collect order details from the endpoint provided by the marketplace.
-
Create a request on the Place fulfillment order endpoint.
-
Simulate fulfillment, to check if the SKU is available in VTEX.
-
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. -
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.
- In the
marketplaceServicesEndpoint
field, the endpoint will be used by VTEX to inform the connector of the changes in order status, inserting tracking code and invoice. For more information check out Sending invoice and tracking code to the marketplace.
- 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.
- Check the Recommendations page to follow integration best practices.
- 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:
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.
_20curl --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:
- In case the call is successful (200 OK), signaling the creation of prive divergence rule, the order should be queued in VTEX.
- 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.
- 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:
- Generate an error log, according to the item x.
- 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. - If the order was not canceled, submit the order to be reprocessed.
- In case the call is successful (200 OK), signaling the creation of the order, connectors should log the operation according to x.
- 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.
- 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:
- Generate an error log, according to the item x.
- 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. - If the order was not canceled, submit the order to be reprocessed.
- In case the call is successful (200 OK), signaling the creation of the order, connectors should log the operation according to x.
- 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.
- 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:
- Generate an error log, according to the item x.
- 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. - If the order was not canceled, submit the order to be reprocessed.
- In case the call is successful (200 OK), signaling the creation of the order, connectors should log the operation according to x.
- 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.
- 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:
-
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.
-
Validate the order status.
-
If the order exists in VTEX, call the Cancel Order endpoint.
-
If the order exists in VTEX, and the order status is
invoiced
, call the Order Invoice notification endpoint. -
In case the call is successful (200 OK), signaling the cancelling of the order, connectors should log the operation according to x.
-
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.
-
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.