We launched a custom checkout page recently using the Wix Stores createOrder() API and today one of the orders were not pushed through after payment (we handle payments, not Wix) due to this error message:
ERROR MESSAGE 1
{"location":"BACKEND","source":"processOrder()","raw":{"stores_error":{"message":"deadline exceeded after 10000518599ns","details":{}},"reason":"WIX_API_FAILURE"}}
Firstly this Wix Stores error message (in bold above) makes no sense to me as a developer, why did this happen?
Second, we have a way to retry the order from the admin side when something like this happens (I did not trust the API so had a dashboard ready for this occasion) however when sent to the createOrder() API the API returns this message:
ERROR MESSAGE 2
{"location":"BACKEND","source":"processOrder()", raw:{"err":{"message":"Insufficient inventory for orderId[Some(693d3ca5-048b-4ce0-8629-aba7fbcc7436)]","details":{}},"reason":"WIX_API_FAILURE_ON_RETRY_FROM_ADMIN"}}
Now we are receiving this error message but here’s the fun part, this time the order is going through and being created however the API is returning an error message.
The function which threw “ERROR MESSAGE 1” above is:
return wixStoresBackend.createOrder(order.orderObject)
.then( (new_order) => {
let order_id = new_order.number;
if(stripe_response.id !== 'FREE_ORDER') {
updateStripe(stripe_response.id, order_id, payment_version);
}
updateDb(stripe_response.id, order_id, order);
return {status: 200, api: stripe_response, orderId: new_order._id};
})
.catch( (err) => {
// Update order status in database with stripe charge id
updateDbFailure(order, stripe_response.id);
// Log error data on google operations
console.log({
location: 'BACKEND',
source: 'processOrder()',
raw: {
stores_error: err,
reason: 'WIX_API_FAILURE'
}
});
return {status: 201, api: stripe_response};
});
The function which threw “ERROR MESSAGE 2” above is:
return wixStoresBackend.createOrder(item.orderObject)
.then( (new_order) => {
let order_id = new_order.number;
if(item.chargeId !== 'FREE_ORDER') {
updateStripe(item.chargeId, order_id);
}
return updateDb(item, order_id);
})
.catch( (err) => {
// Log error data on google operations
console.log({
location: 'BACKEND',
source: 'processOrder()',
raw: {
item: item,
err: err,
reason: 'WIX_API_FAILURE_ON_RETRY_FROM_ADMIN'
}
});
return {status: 400, error: err};
});
The site’s metaID is 9bf8fbe0-b44b-49ef-9643-9793242fde74 and code is called from the Wix Stores Cart page.
This is a problem with the Wix Stores createOrder() API. How can the same order object be rejected 1 hour ago but then accepted with an error response later?