type Shopify = {
token: string;
store_name: string;
};
/**
* Complete a draft order
* Completes a draft order. Using the DraftOrder resource, you can create a draft order and transition it to an order. The following flows are supported: Create a draft order that calculates taxes and totals but accept payment from the customer outside of Shopify. Create a draft order and send an invoice to the customer.
*/
export async function main(
auth: Shopify,
api_version: string = "2023-10",
draft_order_id: string
) {
const url = new URL(
`https://${auth.store_name}.myshopify.com/admin/api/${api_version}/draft_orders/${draft_order_id}/complete.json`
);
const response = await fetch(url, {
method: "PUT",
headers: {
"X-Shopify-Access-Token": auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 396 days ago
type Shopify = {
token: string;
store_name: string;
};
/**
* Complete a draft order
* Completes a draft order. Using the DraftOrder resource, you can create a draft order and transition it to an order. The following flows are supported: Create a draft order that calculates taxes and totals but accept payment from the customer outside of Shopify. Create a draft order and send an invoice to the customer.
*/
export async function main(
auth: Shopify,
api_version: string = "2023-10",
draft_order_id: string
) {
const url = new URL(
`https://${auth.store_name}.myshopify.com/admin/api/${api_version}/draft_orders/${draft_order_id}/complete.json`
);
const response = await fetch(url, {
method: "PUT",
headers: {
"X-Shopify-Access-Token": auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 942 days ago