type Shopify = {
token: string;
store_name: string;
};
/**
* Creates a refund
* Caution For multi-currency orders, the currency property is required whenever the amount property is provided. For more information, see Migrating to support multiple currencies. Creates a refund. Use the calculate endpoint to produce the transactions to submit. Note When you use this endpoint with a Partner development store or a trial store, you can create only five refunds per minute.
*/
export async function main(
auth: Shopify,
api_version: string = "2023-10",
order_id: string,
body: {
refund?: {
currency?: string;
shipping?: { amount?: number; [k: string]: unknown };
transactions?: {
amount?: number;
gateway?: string;
kind?: string;
parent_id?: number;
[k: string]: unknown;
}[];
[k: string]: unknown;
};
[k: string]: unknown;
}
) {
const url = new URL(
`https://${auth.store_name}.myshopify.com/admin/api/${api_version}/orders/${order_id}/refunds.json`
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Shopify-Access-Token": auth.token,
},
body: JSON.stringify(body),
});
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;
};
/**
* Creates a refund
* Caution For multi-currency orders, the currency property is required whenever the amount property is provided. For more information, see Migrating to support multiple currencies. Creates a refund. Use the calculate endpoint to produce the transactions to submit. Note When you use this endpoint with a Partner development store or a trial store, you can create only five refunds per minute.
*/
export async function main(
auth: Shopify,
api_version: string = "2023-10",
order_id: string,
body: {
refund?: {
currency?: string;
shipping?: { amount?: number; [k: string]: unknown };
transactions?: {
amount?: number;
gateway?: string;
kind?: string;
parent_id?: number;
[k: string]: unknown;
}[];
[k: string]: unknown;
};
[k: string]: unknown;
}
) {
const url = new URL(
`https://${auth.store_name}.myshopify.com/admin/api/${api_version}/orders/${order_id}/refunds.json`
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Shopify-Access-Token": auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 942 days ago