Class: ReturnService
Hierarchy
TransactionBaseService
↳
ReturnService
Constructors
constructor
• new ReturnService(__namedParameters
)
Parameters
Name | Type |
---|---|
__namedParameters | InjectedDependencies |
Overrides
TransactionBaseService.constructor
Defined in
medusa/src/services/return.ts:64
Properties
__configModule__
• Protected
Optional
Readonly
__configModule__: Record
<string
, unknown
>
Inherited from
TransactionBaseService.__configModule__
Defined in
medusa/src/interfaces/transaction-base-service.ts:14
__container__
• Protected
Readonly
__container__: any
Inherited from
TransactionBaseService.__container__
Defined in
medusa/src/interfaces/transaction-base-service.ts:13
__moduleDeclaration__
• Protected
Optional
Readonly
__moduleDeclaration__: Record
<string
, unknown
>
Inherited from
TransactionBaseService.__moduleDeclaration__
Defined in
medusa/src/interfaces/transaction-base-service.ts:15
fulfillmentProviderService_
• Protected
Readonly
fulfillmentProviderService_: FulfillmentProviderService
Defined in
medusa/src/services/return.ts:58
lineItemService_
• Protected
Readonly
lineItemService_: LineItemService
Defined in
medusa/src/services/return.ts:55
manager_
• Protected
manager_: EntityManager
Inherited from
TransactionBaseService.manager_
Defined in
medusa/src/interfaces/transaction-base-service.ts:5
orderService_
• Protected
Readonly
orderService_: OrderService
Defined in
medusa/src/services/return.ts:60
productVariantInventoryService_
• Protected
Readonly
productVariantInventoryService_: ProductVariantInventoryService
Defined in
medusa/src/services/return.ts:62
returnItemRepository_
• Protected
Readonly
returnItemRepository_: Repository
<ReturnItem
>
Defined in
medusa/src/services/return.ts:54
returnReasonService_
• Protected
Readonly
returnReasonService_: ReturnReasonService
Defined in
medusa/src/services/return.ts:59
returnRepository_
• Protected
Readonly
returnRepository_: Repository
<Return
>
Defined in
medusa/src/services/return.ts:53
shippingOptionService_
• Protected
Readonly
shippingOptionService_: ShippingOptionService
Defined in
medusa/src/services/return.ts:57
taxProviderService_
• Protected
Readonly
taxProviderService_: TaxProviderService
Defined in
medusa/src/services/return.ts:56
totalsService_
• Protected
Readonly
totalsService_: TotalsService
Defined in
medusa/src/services/return.ts:52
transactionManager_
• Protected
transactionManager_: undefined
| EntityManager
Inherited from
TransactionBaseService.transactionManager_
Defined in
medusa/src/interfaces/transaction-base-service.ts:6
Accessors
activeManager_
• Protected
get
activeManager_(): EntityManager
Returns
EntityManager
Inherited from
TransactionBaseService.activeManager_
Defined in
medusa/src/interfaces/transaction-base-service.ts:8
Methods
atomicPhase_
▸ Protected
atomicPhase_<TResult
, TError
>(work
, isolationOrErrorHandler?
, maybeErrorHandlerOrDontFail?
): Promise
<TResult
>
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
Name |
---|
TResult |
TError |
Parameters
Name | Type | Description |
---|---|---|
work | (transactionManager : EntityManager ) => Promise <TResult > | the transactional work to be done |
isolationOrErrorHandler? | IsolationLevel | (error : TError ) => Promise <void | TResult > | the isolation level to be used for the work. |
maybeErrorHandlerOrDontFail? | (error : TError ) => Promise <void | TResult > | Potential error handler |
Returns
Promise
<TResult
>
the result of the transactional work
Inherited from
TransactionBaseService.atomicPhase_
Defined in
medusa/src/interfaces/transaction-base-service.ts:56
cancel
▸ cancel(returnId
): Promise
<Return
>
Cancels a return if possible. Returns can be canceled if it has not been received.
Parameters
Name | Type | Description |
---|---|---|
returnId | string | the id of the return to cancel. |
Returns
Promise
<Return
>
the updated Return
Defined in
medusa/src/services/return.ts:178
create
▸ create(data
): Promise
<Return
>
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
Name | Type | Description |
---|---|---|
data | CreateReturnInput | data to use for the return e.g. shipping_method, items or refund_amount |
Returns
Promise
<Return
>
the created return
Defined in
medusa/src/services/return.ts:363
fulfill
▸ fulfill(returnId
): Promise
<Return
>
Parameters
Name | Type |
---|---|
returnId | string |
Returns
Promise
<Return
>
Defined in
medusa/src/services/return.ts:507
getFulfillmentItems
▸ Protected
getFulfillmentItems(order
, items
, transformer
): Promise
<LineItem
& { note?
: string
; reason_id?
: string
}[]>
Retrieves the order line items, given an array of items
Parameters
Name | Type | Description |
---|---|---|
order | Order | the order to get line items from |
items | OrdersReturnItem [] | the items to get |
transformer | Transformer | 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
Promise
<LineItem
& { note?
: string
; reason_id?
: string
}[]>
the line items generated by the transformer.
Defined in
medusa/src/services/return.ts:101
list
▸ list(selector
, config?
): Promise
<Return
[]>
Parameters
Name | Type | Description |
---|---|---|
selector | Selector <Return > | the query object for find |
config | FindConfig <Return > | the config object for find |
Returns
Promise
<Return
[]>
the result of the find operation
Defined in
medusa/src/services/return.ts:141
listAndCount
▸ listAndCount(selector
, config?
): Promise
<[Return
[], number
]>
Parameters
Name | Type | Description |
---|---|---|
selector | Selector <Return > | the query object for find |
config | FindConfig <Return > | the config object for find |
Returns
Promise
<[Return
[], number
]>
the result of the find operation
Defined in
medusa/src/services/return.ts:158
receive
▸ receive(returnId
, receivedItems
, refundAmount?
, allowMismatch?
, context?
): Promise
<Return
>
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 sitautions where a custom refund amount is requested, but the retuned items are not matching the requested items. Setting the allowMismatch argument to true, will process the return, ignoring any mismatches.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
returnId | string | undefined | the orderId to return to |
receivedItems | OrdersReturnItem [] | undefined | the items received after return. |
refundAmount? | number | undefined | the amount to return |
allowMismatch | boolean | false | whether to ignore return/received product mismatch |
context | Object | {} | - |
context.locationId? | string | undefined | - |
Returns
Promise
<Return
>
the result of the update operation
Defined in
medusa/src/services/return.ts:578
retrieve
▸ retrieve(returnId
, config?
): Promise
<Return
>
Retrieves a return by its id.
Parameters
Name | Type | Description |
---|---|---|
returnId | string | the id of the return to retrieve |
config | FindConfig <Return > | the config object |
Returns
Promise
<Return
>
the return
Defined in
medusa/src/services/return.ts:276
retrieveBySwap
▸ retrieveBySwap(swapId
, relations?
): Promise
<Return
>
Parameters
Name | Type | Default value |
---|---|---|
swapId | string | undefined |
relations | string [] | [] |
Returns
Promise
<Return
>
Defined in
medusa/src/services/return.ts:304
shouldRetryTransaction_
▸ Protected
shouldRetryTransaction_(err
): boolean
Parameters
Name | Type |
---|---|
err | Record <string , unknown > | { code : string } |
Returns
boolean
Inherited from
TransactionBaseService.shouldRetryTransaction_
Defined in
medusa/src/interfaces/transaction-base-service.ts:37
update
▸ update(returnId
, update
): Promise
<Return
>
Parameters
Name | Type |
---|---|
returnId | string |
update | UpdateReturnInput |
Returns
Promise
<Return
>
Defined in
medusa/src/services/return.ts:329
validateReturnLineItem
▸ Protected
validateReturnLineItem(item?
, quantity?
, additional?
): DeepPartial
<LineItem
>
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
Name | Type | Default value | Description |
---|---|---|---|
item? | LineItem | undefined | the line item to check has sufficient returnable quantity. |
quantity | number | 0 | the quantity that is requested to be returned. |
additional | Object | {} | the quantity that is requested to be returned. |
additional.note? | string | undefined | - |
additional.reason_id? | string | undefined | - |
Returns
DeepPartial
<LineItem
>
a line item where the quantity is set to the requested return quantity.
Defined in
medusa/src/services/return.ts:234
validateReturnStatuses
▸ Protected
validateReturnStatuses(order
): void
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.
Parameters
Name | Type | Description |
---|---|---|
order | Order | the order to check statuses on |
Returns
void
Defined in
medusa/src/services/return.ts:204
withTransaction
▸ withTransaction(transactionManager?
): ReturnService
Parameters
Name | Type |
---|---|
transactionManager? | EntityManager |
Returns
Inherited from
TransactionBaseService.withTransaction