---
displayed_sidebar: servicesSidebar
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# SwapService
Handles swaps
## constructor
### Parameters
___
## Properties
`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"__moduleDeclaration__","type":"`Record`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} />
___
## Accessors
### activeManager\_
#### Returns
___
## Methods
### areReturnItemsValid
#### Parameters
#### Returns
___
### 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
#### Parameters
Promise<TResult>","description":"the transactional work to be done","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"isolationOrErrorHandler","type":"`IsolationLevel` \\| (`error`: TError) => Promise<void \\| TResult>","description":"the isolation level to be used for the work.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"maybeErrorHandlerOrDontFail","type":"(`error`: TError) => Promise<void \\| TResult>","description":"Potential error handler","optional":true,"defaultValue":"","expandable":false,"children":[]}]} />
#### Returns
___
### cancel
Cancels a given swap if possible. A swap can only be canceled if all
related returns, fulfillments, and payments have been canceled. If a swap
is associated with a refund, it cannot be canceled.
#### Parameters
#### Returns
___
### cancelFulfillment
Cancels a fulfillment (if related to a swap)
#### Parameters
#### Returns
___
### create
Creates a swap from an order, with given return items, additional items
and an optional return shipping method.
#### Parameters
#### Returns
___
### createCart
Creates a cart from the given swap. The cart can be used to pay
for differences associated with the swap. The swap represented by the
swapId must belong to the order. Fails if there is already a cart on the
swap.
#### Parameters
#### Returns
___
### createFulfillment
Fulfills the additional items associated with the swap. Will call the
fulfillment providers associated with the shipping methods.
#### Parameters
#### Returns
___
### createShipment
Marks a fulfillment as shipped and attaches tracking numbers.
#### Parameters
#### Returns
___
### deleteMetadata
Dedicated method to delete metadata for a swap.
#### Parameters
#### Returns
___
### list
List swaps.
#### Parameters
#### Returns
___
### listAndCount
List swaps.
#### Parameters
#### Returns
___
### processDifference
Process difference for the requested swap.
#### Parameters
#### Returns
___
### registerCartCompletion
Register a cart completion
#### Parameters
#### Returns
___
### registerReceived
Registers the swap return items as received so that they cannot be used
as a part of other swaps/returns.
#### Parameters
#### Returns
___
### retrieve
Retrieves a swap with the given id.
#### Parameters
#### Returns
___
### retrieveByCartId
Retrieves a swap based on its associated cart id
#### Parameters
#### Returns
___
### shouldRetryTransaction\_
#### Parameters
` \\| `object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} />
#### Returns
___
### transformQueryForCart
Transform find config object for retrieval.
#### Parameters
#### Returns
___
### update
Update the swap record.
#### Parameters
#### Returns
___
### withTransaction
#### Parameters
#### Returns