fix(webshipper): allow cancelling WS orders with error status (#1755)

This commit is contained in:
Sebastian Rindom
2022-07-04 07:57:35 +00:00
committed by GitHub
parent c76e23e84d
commit 1d3032dc67
3 changed files with 21 additions and 12 deletions
@@ -623,19 +623,17 @@ class WebshipperFulfillmentService extends FulfillmentService {
return Promise.resolve()
}
if (order) {
if (
order.data.attributes.status !== "pending" &&
order.data.attributes.status !== "missing_rate"
) {
if (order.data.attributes.status === "cancelled") {
return Promise.resolve(order)
}
throw new Error("Cannot cancel order")
}
if (this.options_.delete_on_cancel) {
return await this.client_.orders.delete(data.id)
}
return this.client_.orders.delete(data.id)
return await this.client_.orders.update(data.id, {
id: data.id,
type: "orders",
attributes: {
status: "cancelled",
},
})
}
}
@@ -83,6 +83,16 @@ class Webshipper {
},
}).then(({ data }) => data)
},
update: async (id, data) => {
const path = `/v2/orders/${id}`
return this.client_({
method: "PATCH",
url: path,
data: {
data,
},
}).then(({ data }) => data)
},
delete: async (id) => {
const path = `/v2/orders/${id}`
return this.client_({