# Class: ReturnService

Handles Returns

## Hierarchy

- `"medusa-interfaces"`

  ↳ **`ReturnService`**

## Constructors

### constructor

• **new ReturnService**(`__namedParameters`)

#### Parameters

| Name | Type |
| :------ | :------ |
| `__namedParameters` | `Object` |

#### Overrides

BaseService.constructor

#### Defined in

[services/return.js:9](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L9)

## Properties

### inventoryService\_

• **inventoryService\_**: `any`

#### Defined in

[services/return.js:49](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L49)

___

### returnReasonService\_

• **returnReasonService\_**: `any`

#### Defined in

[services/return.js:47](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L47)

___

### taxProviderService\_

• **taxProviderService\_**: `any`

#### Defined in

[services/return.js:39](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L39)

## Methods

### 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

[services/return.js:134](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L134)

___

### 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` | `any` | data to use for the return e.g. shipping_method,    items or refund_amount |

#### Returns

`Promise`<`Return`\>

the created return

#### Defined in

[services/return.js:307](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L307)

___

### fulfill

▸ **fulfill**(`returnId`): `any`

#### Parameters

| Name | Type |
| :------ | :------ |
| `returnId` | `any` |

#### Returns

`any`

#### Defined in

[services/return.js:450](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L450)

___

### getFulfillmentItems\_

▸ **getFulfillmentItems_**(`order`, `items`, `transformer`): `Promise`<`LineItem`[]\>

Retrieves the order line items, given an array of items

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `order` | `Order` | the order to get line items from |
| `items` | `Object` | the items to get |
| `items.item_id` | `string` | - |
| `items.quantity` | `number` | - |
| `transformer` | `Function` | 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`[]\>

the line items generated by the transformer.

#### Defined in

[services/return.js:89](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L89)

___

### list

▸ **list**(`selector`, `config?`): `Promise`<`any`\>

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `selector` | `any` | the query object for find |
| `config` | `any` | the config object for find |

#### Returns

`Promise`<`any`\>

the result of the find operation

#### Defined in

[services/return.js:120](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L120)

___

### receive

▸ **receive**(`return_id`, `received_items`, `refund_amount`, `allow_mismatch?`): `Promise`<`any`\>

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 |
| :------ | :------ | :------ | :------ |
| `return_id` | `string` | `undefined` | the orderId to return to |
| `received_items` | `Item`[] | `undefined` | the items received after return. |
| `refund_amount` | `undefined` \| `number` | `undefined` | the amount to return |
| `allow_mismatch` | `bool` | `false` | whether to ignore return/received product mismatch |

#### Returns

`Promise`<`any`\>

the result of the update operation

#### Defined in

[services/return.js:524](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L524)

___

### retrieve

▸ **retrieve**(`id`, `config?`): `Return`

Retrieves a return by its id.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `id` | `string` | the id of the return to retrieve |
| `config` | `any` | the config object |

#### Returns

`Return`

the return

#### Defined in

[services/return.js:229](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L229)

___

### retrieveBySwap

▸ **retrieveBySwap**(`swapId`, `relations?`): `Promise`<`any`\>

#### Parameters

| Name | Type | Default value |
| :------ | :------ | :------ |
| `swapId` | `any` | `undefined` |
| `relations` | `any`[] | `[]` |

#### Returns

`Promise`<`any`\>

#### Defined in

[services/return.js:248](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L248)

___

### update

▸ **update**(`returnId`, `update`): `Promise`<`any`\>

#### Parameters

| Name | Type |
| :------ | :------ |
| `returnId` | `any` |
| `update` | `any` |

#### Returns

`Promise`<`any`\>

#### Defined in

[services/return.js:271](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L271)

___

### validateReturnLineItem\_

▸ **validateReturnLineItem_**(`item`, `quantity`, `additional`): `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 | Description |
| :------ | :------ | :------ |
| `item` | `any` | the line item to check has sufficient returnable   quantity. |
| `quantity` | `number` | the quantity that is requested to be returned. |
| `additional` | `any` | the quantity that is requested to be returned. |

#### Returns

`LineItem`

a line item where the quantity is set to the requested
  return quantity.

#### Defined in

[services/return.js:191](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L191)

___

### validateReturnStatuses\_

▸ **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

[services/return.js:161](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L161)

___

### withTransaction

▸ **withTransaction**(`transactionManager`): [`ReturnService`](ReturnService.md)

#### Parameters

| Name | Type |
| :------ | :------ |
| `transactionManager` | `any` |

#### Returns

[`ReturnService`](ReturnService.md)

#### Defined in

[services/return.js:55](https://github.com/medusajs/medusa/blob/2d3e404f/packages/medusa/src/services/return.js#L55)
