Skip to content

ReturnModule

Module in @evolve-framework/commercetools

Returns on commercetools, for consumers and business units: requesting one for delivered lines of an order, with a reason per line, serial numbers and photos where they are needed, a refund method for a consumer and a restocking fee for a late business return; handing it in at a service point or having it collected; and withdrawing it while it has not left.

import { ReturnModule } from "@evolve-framework/commercetools";

Serves the Return part of the GraphQL API: returnEstimate, returnExchangeOptions, returnReasons, returnAttachmentUpload, returnCancel, returnCreate.

new ReturnModule(options: ReturnModuleOptions)
OptionTypeDescription
clientFactoryClientFactory

The commercetools client its requests to the project go through, built with ClientFactory.create.

customTypesPick<CustomTypeKeys, "order-return-item">

Key of the custom type the project has provisioned for return items (order-return-item). It needs reasonCode, returnStatus, returnRequest and, where returns are approved, returnDecision String fields.

carrierReturnCarrierProvider

Who carries returns back: demoReturnCarrier, or a carrier's API behind the same type. Its methods decide which shipping methods are offered.

reasons?ReturnReasonConfig[]

The reasons a buyer chooses from. Defaults to demoReturnReasons.

windowDays?number | null

Days after delivery a consumer's line can be returned. Defaults to 14, the withdrawal period EU law gives a consumer; null sets no deadline.

businessWindowDays?number | null

Days after delivery a business unit's line can be returned. No deadline by default: a late return costs the restocking fee instead.

restockingFee?RestockingFeeSetting | null

The fee withheld from a business unit's credit for a late return, the same for every unit. Defaults to 15% after 14 free days; null for none.

refundMethods?ReturnRefundMethodType[]

How a consumer's refund may be paid. Defaults to both methods.

returnAddress?BaseAddress

Where a buyer sends a return themselves; without it they cannot.

attachments?AttachmentStore

Where photos are kept; without one a return takes none.

serialNumberAttribute?string

The Boolean variant attribute that marks a device, whose return needs a serial number per unit. Without one no line asks for serial numbers.

messagePublisher?MessagePublisher

Where return-requested is published, for an ERP that approves returns. Its decisions come back as internal events this module handles.

origin?string

The origin of the events this module publishes. Defaults to commercetools.

ReturnCarrierProvider3The fields of carrier.
FieldTypeDescription
dropOff?((request: ReturnShipmentRequest) => Promise<ReturnDropOffShipment>)
pickup?((request: ReturnShipmentRequest & { address: BaseAddress; date?: string | undefined; }) => Promise<ReturnPickupShipment>)
cancel?((returnNumber: string) => Promise<void>)

Called when a return is withdrawn, to void what was booked.

ReturnReasonConfig3The fields of reasons.
FieldTypeDescription
codestring
labelRecord<string, string>
requiresPhotos?boolean

Whether a line returned for this reason needs a photo. Defaults to false.

AttachmentStore3The fields of attachments.
FieldTypeDescription
contentTypesstring[]

The content types it accepts, such as image/jpeg.

createUpload(request: { filename: string; contentType: string; customerId: string; }) => Promise<{ attachmentId: string; uploadUrl: string; expiresAt: string; }>
read(attachmentId: string, customerId: string) => Promise<StoredAttachment | undefined>

Undefined when the id is unknown, was never uploaded, or is not the customer's.

Extends AbstractModule<CommercetoolsLoaderContext>.