Skip to main content
Skip to main content

ReturnService

constructor

Parameters

__namedParametersInjectedDependenciesRequired

Properties

manager_EntityManagerRequired
transactionManager_undefined | EntityManagerRequired
__container__anyRequired
totalsService_TotalsServiceRequired
returnRepository_Repository<Return>Required
returnItemRepository_Repository<ReturnItem>Required
lineItemService_LineItemServiceRequired
taxProviderService_TaxProviderServiceRequired
shippingOptionService_ShippingOptionServiceRequired
fulfillmentProviderService_FulfillmentProviderServiceRequired
returnReasonService_ReturnReasonServiceRequired
orderService_OrderServiceRequired
productVariantInventoryService_ProductVariantInventoryServiceRequired
featureFlagRouter_FlagRouterRequired
__configModule__Record<string, unknown>
__moduleDeclaration__Record<string, unknown>

Accessors

activeManager_

Returns

EntityManagerEntityManagerRequired

Methods

withTransaction

Parameters

transactionManagerEntityManager

Returns

thisthisRequired

shouldRetryTransaction_

Parameters

errRecord<string, unknown> | objectRequired

Returns

booleanbooleanRequired

atomicPhase_

Wraps some work within a transactional block. If the service already has a transaction manager attached this will be reused, otherwise a new transaction manager is created.

Type Parameters

TResultobjectRequired
TErrorobjectRequired

Parameters

work(transactionManager: EntityManager) => Promise<TResult>Required
the transactional work to be done
isolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>
the isolation level to be used for the work.
maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>
Potential error handler

Returns

PromisePromise<TResult>Required
the result of the transactional work

getFulfillmentItems

Retrieves the order line items, given an array of items

Parameters

orderOrderRequired
the order to get line items from
itemsOrdersReturnItem[]Required
the items to get
transformerTransformerRequired
a function to apply to each of the items retrieved from the order, should return a line item. If the transformer returns an undefined value the line item will be filtered from the returned array.

Returns

PromisePromise<LineItem & object[]>Required
the line items generated by the transformer.

list

Parameters

selectorSelector<Return>Required
the query object for find
configFindConfig<Return>Required
the config object for find

Returns

PromisePromise<Return[]>Required
the result of the find operation

listAndCount

Parameters

selectorSelector<Return>Required
the query object for find
configFindConfig<Return>Required
the config object for find

Returns

PromisePromise<[Return[], number]>Required
the result of the find operation

cancel

Cancels a return if possible. Returns can be canceled if it has not been received.

Parameters

returnIdstringRequired
the id of the return to cancel.

Returns

PromisePromise<Return>Required
the updated Return

validateReturnStatuses

Checks that an order has the statuses necessary to complete a return. fulfillment_status cannot be not_fulfilled or returned. payment_status must be captured.

Parameters

orderOrderRequired
the order to check statuses on

Returns

voidvoidRequired
Checks that an order has the statuses necessary to complete a return. fulfillment_status cannot be not_fulfilled or returned. payment_status must be captured.

Throws

when statuses are not sufficient for returns.

validateReturnLineItem

Checks that a given quantity of a line item can be returned. Fails if the item is undefined or if the returnable quantity of the item is lower, than the quantity that is requested to be returned.

Parameters

quantitynumberRequired
the quantity that is requested to be returned.

Default: 0

additionalobjectRequired
the quantity that is requested to be returned.

Default: {}

the line item to check has sufficient returnable quantity.
additional.reason_idstring
additional.notestring

Returns

DeepPartialDeepPartial<LineItem>Required
a line item where the quantity is set to the requested return quantity.

retrieve

Retrieves a return by its id.

Parameters

returnIdstringRequired
the id of the return to retrieve
configFindConfig<Return>Required
the config object

Default: {}

Returns

PromisePromise<Return>Required
the return

retrieveBySwap

Parameters

swapIdstringRequired
relationsstring[]Required

Default: []

Returns

PromisePromise<Return>Required

update

Parameters

returnIdstringRequired
updateUpdateReturnInputRequired

Returns

PromisePromise<Return>Required

create

Creates a return request for an order, with given items, and a shipping method. If no refund amount is provided the refund amount is calculated from the return lines and the shipping cost.

Parameters

dataCreateReturnInputRequired
data to use for the return e.g. shipping_method, items or refund_amount

Returns

PromisePromise<Return>Required
the created return

fulfill

Parameters

returnIdstringRequired

Returns

PromisePromise<Return>Required

receive

Registers a previously requested return as received. This will create a refund to the customer. If the returned items don't match the requested items the return status will be updated to requires_action. This behaviour is useful in situations where a custom refund amount is requested, but the returned items are not matching the requested items. Setting the allowMismatch argument to true, will process the return, ignoring any mismatches.

Parameters

returnIdstringRequired
the orderId to return to
receivedItemsOrdersReturnItem[]Required
the items received after return.
allowMismatchbooleanRequired
whether to ignore return/received product mismatch

Default: false

contextobjectRequired

Default: {}

refundAmountnumber
the amount to return
context.locationIdstring

Returns

PromisePromise<Return>Required
the result of the update operation
Was this section helpful?