shipmentCancelled()
This method is called when a shipment is cancelled for one or more items in one or more sales orders. A single shipment may contain items from multiple sales orders, and a single sales order may be fulfilled by multiple shipments.
Syntax
module.exports = async function shipmentCancelled(transaction, shipment) { // Your code here}
import { Transaction, SalesOrderShipment } from "@shipengine/connect";export default async function shipmentCancelled( transaction: Transaction, shipment: SalesOrderShipment): Promise<void> { // Your code here}
Parameters
transaction
A transaction object containing information about the transaction and session state.
shipment
The shipment that was cancelled.
Name | Type | Nullable? | Description |
---|---|---|---|
trackingNumber | string | The master tracking number for the entire shipment. For single-piece shipments, this will be the same as the package tracking number. For multi-piece shipments, this may be a separate tracking number, or the same tracking number as one of the packages. This string will not contain newline characters. | |
identifiers | object | Your own identifiers for this shipment. | |
trackingURL | ✔ | The URL of a webpage where the customer can track the shipment. | |
salesOrder | object | The sales order associated with this shipment. | |
salesOrder.id | The marketplace's unique ID for the sales order. | ||
salesOrder.identifiers | object | Your own identifiers for this sales order. | |
fulfillmentService | string | ✔ | If the shipment is being fulfilled using a well-known third-party carrier, such as UPS, FedEx, DHL, etc., then this field specifies the carrier service. |
shipFrom | ✔ | The sender's contact info and address. | |
shipTo | The recipient's contact info and address. | ||
shipDateTime | The date/time that the shipment was shipped or is expected to ship. This is not guaranteed to be in the future. | ||
contents | object[] | The items inside the package. | |
contents[].salesOrderItem | object | ✔ | The sales order associated with this item. |
contents[]
.salesOrderItem
.id | string | The marketplace's unique ID for the sales order item. | |
contents[]
.salesOrderItem
.sku | string | The Stock Keeping Unit. This string must not contain newline characters. | |
contents[]
.salesOrderItem
.identifiers | object | Your own identifiers for this sales order item. | |
contents[].product | object | The product associated with this item. | |
contents[].product.id | string | The product catalog's unique ID for the order. This string must not contain newline characters. | |
contents[].product.sku | string | The Stock Keeping Unit. This string must not contain newline characters. | |
contents[].product.upc | string | The Universal Product Code for this item. This string must not contain newline characters. | |
contents[].product.isbn | string | The International Standard Book Number for this item. This string must not contain newline characters. | |
contents[].product.asin | string | The Amazon Standard Identification Number for this item. This string must not contain newline characters. | |
contentes[]
.product
.fulfillmentSku | string | The Stock Keeping Unit related to the fulfillment of this item. This string must not contain newline characters. | |
contents[]
.product
.inventoryID | string | The inventory ID for this item. This string must not contain newline characters. | |
contents[]
.product
.identifiers | object | Your own identifiers for this product. | |
contents[]
.product
.details | A list of details associated with this product. |
Return Value
void
This method is used to notify your application when a shipment is cancelled. It does not return a value.
Example
async function shipmentCancelled(transaction, shipment) { // STEP 1: Validation // Add any desired validation here // STEP 2: Create the data that the order source's API expects const data = { operation: "cancel_shipment", session_id: transaction.session.id, cancelled_shipment_id: shipment.trackingNumber }; // STEP 3: Call the order source's API await apiClient.request({ data });}
export default async function shipmentCancelled( transaction: Transaction<Session>, shipment: SalesOrderShipment,): Promise<void> { // STEP 1: Validation // Add any desired validation here // STEP 2: Create the data that the order source's API expects const data = { operation: "cancel_shipment", session_id: transaction.session.id, cancelled_shipment_id: shipment.trackingNumber }; // STEP 3: Call the order source's API await apiClient.request({ data });}