Complete Order
Completes an order using a checkoutId.
Save this example as 05-complete-order.mjs.
import { printJson, readConfig, thyrisRequest } from "./thyris-client.mjs"
const config = readConfig()
const checkoutId = process.env.THYRIS_CHECKOUT_ID || process.argv[2]
const paymentId = process.env.THYRIS_PAYMENT_ID || process.argv[3]
if (!checkoutId) {
throw new Error("Pass a checkoutId as the first argument or set THYRIS_CHECKOUT_ID")
}
const result = await thyrisRequest(config, "/api/v1/catalog/orders", {
method: "POST",
body: JSON.stringify({
checkoutId,
...(paymentId ? { payment: { id: paymentId, status: "paid", provider: "sample-script" } } : {}),
customer: {
name: "Demo Customer",
email: "demo.customer@example.com",
phone: "+15551112233",
},
shippingAddress: {
line1: "Example Street 1",
city: "Example City",
country: "US",
postalCode: "10001",
},
otherDetails: {
source: "scripts",
},
}),
})
printJson(result)