Order is not printing square stand but present in the new order section.Is there any wrong with my order object?
I’m trying to make the order via using Node JS api and It’s worked. My order was created and payment was successful and also present in the new order section on my iPad. But this order is not printing.
Is there any wrong with my order object can u guys check this, please? Thanks
This is my code implementation:-
// Make an order
async createOrder(req: Request, res: Response) {
try {
appLogger.info("Create order start");
const ordersApi = this.client.ordersApi;
const createOrderRequest: OrderDto = req.body;
const order = squareOrderCreateRequestBody(createOrderRequest);
const createPaymentRequest: PaymentDto = req.body;
const response = await ordersApi.createOrder(order);
if (response.result) {
appLogger.info("Order create success");
const isPayed = await this.makePayment(
createPaymentRequest,
response.result.order,
res
);
return res
.status(200)
.json(
serializeBigInts({ order: response.result.order, payment: isPayed })
);
}
} catch (error) {
console.log(error);
appLogger.error(`Error make order:", ${error}`);
return handleError({ error }, res);
}
}
import {
CreateOrderRequest,
Fulfillment,
OrderLineItem,
} from "square";
import { v4 as uuidv4 } from "uuid";
import { OrderDto } from "../modules/square/dto/order.dto";
export function squareOrderCreateRequestBody(
dto: OrderDto
): CreateOrderRequest {
const order: CreateOrderRequest = {
order: {
locationId: dto.locationId,
referenceId: `ref-${uuidv4()}`,
customerId: dto.customerId,
lineItems: dto.lineItems.map((product: OrderLineItem): OrderLineItem => {
return {
quantity: product.quantity,
catalogObjectId: product.catalogObjectId,
basePriceMoney: {
amount: BigInt(product.basePriceMoney.amount),
currency: "AUD",
},
modifiers:
product?.modifiers?.length > 0 &&
product?.modifiers?.map((modifier) => {
return {
catalogObjectId: modifier.catalogObjectId,
quantity: modifier.quantity,
basePriceMoney: {
amount: BigInt(modifier.basePriceMoney.amount),
currency: "AUD",
},
};
}),
};
}),
fulfillments: dto.lineItems.map((item: OrderLineItem): Fulfillment => {
return {
type: "PICKUP",
state: "PROPOSED",
pickupDetails: {
recipient: {
displayName: dto.customerId,
},
//expiresAt: "2019-02-14T20:21:54.859Z",
//autoCompleteDuration: "P0DT1H0S",
//scheduleType: "SCHEDULED",
pickupAt: "2023-10-20T23:59:33.123Z",
note: "Pour over coffee",
},
};
}),
},
idempotencyKey: uuidv4(),
};
return order;
}