ReturnService
Hierarchy
TransactionBaseService
↳
ReturnService
Constructors
constructor
new ReturnService(«destructured»
)
Parameters
Name |
---|
«destructured» |
Overrides
TransactionBaseService.constructor
Defined in
medusa/src/services/return.ts:68
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
featureFlagRouter_
Protected
Readonly
featureFlagRouter_: FlagRouter
Defined in
medusa/src/services/return.ts:66
fulfillmentProviderService_
Protected
Readonly
fulfillmentProviderService_: FulfillmentProviderService
Defined in
medusa/src/services/return.ts:61
lineItemService_
Protected
Readonly
lineItemService_: LineItemService
Defined in
medusa/src/services/return.ts:58
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:63
productVariantInventoryService_
Protected
Readonly
productVariantInventoryService_: ProductVariantInventoryService
Defined in
medusa/src/services/return.ts:65
returnItemRepository_
Protected
Readonly
returnItemRepository_: Repository
<ReturnItem
>
Defined in
medusa/src/services/return.ts:57
returnReasonService_
Protected
Readonly
returnReasonService_: ReturnReasonService
Defined in
medusa/src/services/return.ts:62
returnRepository_
Protected
Readonly
returnRepository_: Repository
<Return
>
Defined in
medusa/src/services/return.ts:56
shippingOptionService_
Protected
Readonly
shippingOptionService_: ShippingOptionService
Defined in
medusa/src/services/return.ts:60
taxProviderService_
Protected
Readonly
taxProviderService_: TaxProviderService
Defined in
medusa/src/services/return.ts:59
totalsService_
Protected
Readonly
totalsService_: TotalsService
Defined in
medusa/src/services/return.ts:55
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
-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.
Name |
---|
TResult |
TError |
Parameters
Name | Description |
---|---|
work | (transactionManager : EntityManager ) => Promise <TResult > |
isolationOrErrorHandler? | IsolationLevel | (error : TError ) => Promise <void | TResult > |
maybeErrorHandlerOrDontFail? | (error : TError ) => Promise <void | TResult > |
Returns
Promise
<TResult
>
-Promise
: 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 | Description |
---|---|
returnId | string |
Returns
Promise
<Return
>
-Promise
: the updated Return
-Return
:
Defined in
medusa/src/services/return.ts:184
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 | Description |
---|---|
data | CreateReturnInput |
Returns
Promise
<Return
>
-Promise
: the created return
-Return
:
Defined in
medusa/src/services/return.ts:369
fulfill
fulfill(returnId
): Promise
<Return
>
Parameters
Name |
---|
returnId |
Returns
Promise
<Return
>
-Promise
:
-Return
:
Defined in
medusa/src/services/return.ts:535
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 | Description |
---|---|
order | Order |
items | OrdersReturnItem [] |
transformer | Transformer |
Returns
Promise
<LineItem
& { note?
: string
; reason_id?
: string
}[]>
-Promise
: the line items generated by the transformer.
-LineItem` & { `note?`: `string` ; `reason_id?`: `string` }[]`:
-
LineItem& {
note?:
string;
reason_id?:
string }
: (optional)
Defined in
medusa/src/services/return.ts:107
list
list(selector
, config?
): Promise
<Return
[]>
Parameters
Name | Description |
---|---|
selector | Selector <Return > |
config | FindConfig <Return > |
Returns
Promise
<Return
[]>
-Promise
: the result of the find operation
-Return[]
:
-Return
:
Defined in
medusa/src/services/return.ts:147
listAndCount
listAndCount(selector
, config?
): Promise
<[Return
[], number
]>
Parameters
Name | Description |
---|---|
selector | Selector <Return > |
config | FindConfig <Return > |
Returns
Promise
<[Return
[], number
]>
-Promise
: the result of the find operation
-Return[]
:
-number
: (optional)
Defined in
medusa/src/services/return.ts:164
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 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
Name | Default value | Description |
---|---|---|
returnId | string | the orderId to return to |
receivedItems | OrdersReturnItem [] | the items received after return. |
refundAmount? | number | the amount to return |
allowMismatch | boolean | false |
context | object | |
context.locationId? | string |
Returns
Promise
<Return
>
-Promise
: the result of the update operation
-Return
:
Defined in
medusa/src/services/return.ts:608
retrieve
retrieve(returnId
, config?
): Promise
<Return
>
Retrieves a return by its id.
Parameters
Name | Description |
---|---|
returnId | string |
config | FindConfig <Return > |
Returns
Promise
<Return
>
-Promise
: the return
-Return
:
Defined in
medusa/src/services/return.ts:282
retrieveBySwap
retrieveBySwap(swapId
, relations?
): Promise
<Return
>
Parameters
Name | Default value |
---|---|
swapId | string |
relations | string [] |
Returns
Promise
<Return
>
-Promise
:
-Return
:
Defined in
medusa/src/services/return.ts:310
shouldRetryTransaction_
Protected
shouldRetryTransaction_(err
): boolean
Parameters
Name |
---|
err |
Returns
boolean
-boolean
: (optional)
Inherited from
TransactionBaseService.shouldRetryTransaction_
Defined in
medusa/src/interfaces/transaction-base-service.ts:37
update
update(returnId
, update
): Promise
<Return
>
Parameters
Name |
---|
returnId |
update |
Returns
Promise
<Return
>
-Promise
:
-Return
:
Defined in
medusa/src/services/return.ts:335
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 | Default value | Description |
---|---|---|
item? | LineItem | the line item to check has sufficient returnable quantity. |
quantity | number | 0 |
additional | object | the quantity that is requested to be returned. |
additional.note? | string | |
additional.reason_id? | string |
Returns
DeepPartial
<LineItem
>
-DeepPartial
: a line item where the quantity is set to the requested
return quantity.
-LineItem
:
Defined in
medusa/src/services/return.ts:240
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.
Parameters
Name | Description |
---|---|
order | Order |
Returns
void
-void
: (optional)
Throws
when statuses are not sufficient for returns.
Defined in
medusa/src/services/return.ts:210
withTransaction
withTransaction(transactionManager?
): ReturnService
Parameters
Name |
---|
transactionManager? |
Returns
-ReturnService
:
Inherited from
TransactionBaseService.withTransaction