-
Notifications
You must be signed in to change notification settings - Fork 789
Open
Description
I am trying to figure it out, but an example may help more. I am seeing the following issue:
function getOrderRequest(key, locationId, body) {
const date = new Date();
return {
idempotencyKey: key,
order: {
locationId: locationId,
lineItems: [{
name: body.name,
quantity: body.quantity,
basePriceMoney: {
amount: body.amount,
currency: "USD"
}
}],
"fulfillments": [{
"type": "SHIPMENT",
"state": "PROPOSED",
"placed_at": date.toISOString(),
"line_item_application": "ALL",
"shipment_details": {
"carrier": body.shipment_details.carrier,
"recipient": {
"display_name": body.shipment_details.recipient.display_name,
"email_address": body.shipment_details.recipient.email_address,
"phone_number": body.shipment_details.recipient.phone_number,
"address": {
"address_line_1": body.shipment_details.recipient.address.address_line_1,
"administrative_district_level_1": body.shipment_details.recipient.address.administrative_district_level_1, //state
"country": body.shipment_details.recipient.address.country,
"locality": body.shipment_details.recipient.address.locality, //city
"postal_code": body.shipment_details.recipient.address.postal_code,
}
}
}
}]
}
}
}
exports.zeedy = async (req, res) => {
const requestBody = req.body;
console.log('start body')
console.log(requestBody)
console.log('end body')
const bytes = randomBytes(12).toString('hex')
try {
const locationId = process.env.locationId;
console.log(locationId)
const createOrderRequest = getOrderRequest(bytes, locationId, requestBody);
console.log('createOrderRequest created')
console.log(createOrderRequest.order.fulfillments[0].shipment_details)
console.log('end details')
const createOrderResponse = await ordersApi.createOrder(createOrderRequest);
It failed on createOrder with:
"detail": "Fulfillments of type SHIPMENT must have shipment_details supplied.",
"field": "order.fulfillments[0].shipment_details",
but the values are there when logged. An example would be great.
Metadata
Metadata
Assignees
Labels
No labels