---
displayed_sidebar: servicesSidebar
---

import ParameterTypes from "@site/src/components/ParameterTypes"

# FulfillmentProviderService

Helps retrieve fulfillment providers

## constructor

`**new FulfillmentProviderService**(container)`

### Parameters

<ParameterTypes parameters={[
  {
    "name": "container",
    "type": "[FulfillmentProviderContainer](../types/FulfillmentProviderContainer.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

___

## Properties

<ParameterTypes parameters={[
  {
    "name": "__configModule__",
    "type": "`Record<string, unknown>`",
    "description": "",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "__container__",
    "type": "`any`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "__moduleDeclaration__",
    "type": "`Record<string, unknown>`",
    "description": "",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "container_",
    "type": "[FulfillmentProviderContainer](../types/FulfillmentProviderContainer.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "fulfillmentProviderRepository_",
    "type": "Repository&#60;[FulfillmentProvider](FulfillmentProvider.mdx)&#62;",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "manager_",
    "type": "EntityManager",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "transactionManager_",
    "type": "`undefined` \\| EntityManager",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

___

## Accessors

### activeManager\_

`Protected get**activeManager_**(): EntityManager`

#### Returns

EntityManager

<ParameterTypes parameters={[
  {
    "name": "EntityManager",
    "type": "EntityManager",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

## Methods

### atomicPhase\_

`Protected **atomicPhase_**<TypeParameter TResult, TypeParameter TError>(work, isolationOrErrorHandler?, maybeErrorHandlerOrDontFail?): Promise&#60;TResult&#62;`

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

<ParameterTypes parameters={[
  {
    "name": "TResult",
    "type": "`object`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "TError",
    "type": "`object`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "work",
    "type": "(`transactionManager`: EntityManager) => Promise&#60;TResult&#62;",
    "description": "the transactional work to be done",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "isolationOrErrorHandler",
    "type": "`IsolationLevel` \\| (`error`: `TError`) => Promise&#60;void \\| TResult&#62;",
    "description": "the isolation level to be used for the work.",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "maybeErrorHandlerOrDontFail",
    "type": "(`error`: `TError`) => Promise&#60;void \\| TResult&#62;",
    "description": "Potential error handler",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;TResult&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;TResult&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "the result of the transactional work",
    "expandable": false,
    "children": []
  }
]} />

___

### calculatePrice

`**calculatePrice**(option, data, cart?): Promise&#60;number&#62;`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "option",
    "type": "[ShippingOption](ShippingOption.mdx)",
    "description": "A Shipping Option represents a way in which an Order or Return can be shipped. Shipping Options have an associated Fulfillment Provider that will be used when the fulfillment of an Order is initiated. Shipping Options themselves cannot be added to Carts, but serve as a template for Shipping Methods. This distinction makes it possible to customize individual Shipping Methods with additional information.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "data",
    "type": "`Record<string, unknown>`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "cart",
    "type": "[Order](Order.mdx) \\| [Cart](Cart.mdx)",
    "description": "",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;number&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;number&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

### canCalculate

`**canCalculate**(option): Promise&#60;boolean&#62;`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "option",
    "type": "[CalculateOptionPriceInput](../types/CalculateOptionPriceInput.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;boolean&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;boolean&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

### cancelFulfillment

`**cancelFulfillment**(fulfillment): Promise&#60;[Fulfillment](Fulfillment.mdx)&#62;`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "fulfillment",
    "type": "[Fulfillment](Fulfillment.mdx)",
    "description": "A Fulfillment is created once an admin can prepare the purchased goods. Fulfillments will eventually be shipped and hold information about how to track shipments. Fulfillments are created through a fulfillment provider, which typically integrates a third-party shipping service. Fulfillments can be associated with orders, claims, swaps, and returns.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;[Fulfillment](Fulfillment.mdx)&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[Fulfillment](Fulfillment.mdx)&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

### createFulfillment

`**createFulfillment**(method, items, order, fulfillment): Promise&#60;Record&#60;string, unknown&#62;&#62;`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "method",
    "type": "[ShippingMethod](ShippingMethod.mdx)",
    "description": "A Shipping Method represents a way in which an Order or Return can be shipped. Shipping Methods are created from a Shipping Option, but may contain additional details that can be necessary for the Fulfillment Provider to handle the shipment. If the shipping method is created for a return, it may be associated with a claim or a swap that the return is part of.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "items",
    "type": "[LineItem](LineItem.mdx)[]",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "order",
    "type": "[CreateFulfillmentOrder](../types/CreateFulfillmentOrder.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "fulfillment",
    "type": "[Omit](../types/Omit.mdx)&#60;[Fulfillment](Fulfillment.mdx), \"beforeInsert\"&#62;",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;Record&#60;string, unknown&#62;&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;Record&#60;string, unknown&#62;&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

### createReturn

`**createReturn**(returnOrder): Promise&#60;Record&#60;string, unknown&#62;&#62;`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "returnOrder",
    "type": "[CreateReturnType](../types/CreateReturnType.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;Record&#60;string, unknown&#62;&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;Record&#60;string, unknown&#62;&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

### list

`**list**(): Promise&#60;[FulfillmentProvider](FulfillmentProvider.mdx)[]&#62;`

#### Returns

Promise&#60;[FulfillmentProvider](FulfillmentProvider.mdx)[]&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[FulfillmentProvider](FulfillmentProvider.mdx)[]&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

### listFulfillmentOptions

`**listFulfillmentOptions**(providerIds): Promise&#60;[FulfillmentOptions](../types/FulfillmentOptions.mdx)[]&#62;`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "providerIds",
    "type": "`string`[]",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;[FulfillmentOptions](../types/FulfillmentOptions.mdx)[]&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[FulfillmentOptions](../types/FulfillmentOptions.mdx)[]&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

### registerInstalledProviders

`**registerInstalledProviders**(providers): Promise&#60;void&#62;`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "providers",
    "type": "`string`[]",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;void&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;void&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

### retrieveDocuments

`**retrieveDocuments**(providerId, fulfillmentData, documentType): Promise&#60;any&#62;`

Fetches documents from the fulfillment provider

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "providerId",
    "type": "`string`",
    "description": "the id of the provider",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "fulfillmentData",
    "type": "`Record<string, unknown>`",
    "description": "the data relating to the fulfillment",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "documentType",
    "type": "`\"label\"` \\| `\"invoice\"`",
    "description": "the typ of",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;any&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;any&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "document to fetch",
    "expandable": false,
    "children": []
  }
]} />

___

### retrieveProvider

`**retrieveProvider**(providerId): any`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "providerId",
    "type": "`string`",
    "description": "the provider id",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

`any`

<ParameterTypes parameters={[
  {
    "name": "any",
    "type": "`any`",
    "optional": true,
    "defaultValue": "",
    "description": "the payment fulfillment provider",
    "expandable": false,
    "children": []
  }
]} />

___

### shouldRetryTransaction\_

`Protected **shouldRetryTransaction_**(err): boolean`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "err",
    "type": "`Record<string, unknown>` \\| ``{ code: string  }``",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

`boolean`

<ParameterTypes parameters={[
  {
    "name": "boolean",
    "type": "`boolean`",
    "optional": true,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

### validateFulfillmentData

`**validateFulfillmentData**(option, data, cart): Promise&#60;Record&#60;string, unknown&#62;&#62;`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "option",
    "type": "[ShippingOption](ShippingOption.mdx)",
    "description": "A Shipping Option represents a way in which an Order or Return can be shipped. Shipping Options have an associated Fulfillment Provider that will be used when the fulfillment of an Order is initiated. Shipping Options themselves cannot be added to Carts, but serve as a template for Shipping Methods. This distinction makes it possible to customize individual Shipping Methods with additional information.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "data",
    "type": "`Record<string, unknown>`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "cart",
    "type": "`Record<string, unknown>` \\| [Cart](Cart.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;Record&#60;string, unknown&#62;&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;Record&#60;string, unknown&#62;&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

### validateOption

`**validateOption**(option): Promise&#60;boolean&#62;`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "option",
    "type": "[ShippingOption](ShippingOption.mdx)",
    "description": "A Shipping Option represents a way in which an Order or Return can be shipped. Shipping Options have an associated Fulfillment Provider that will be used when the fulfillment of an Order is initiated. Shipping Options themselves cannot be added to Carts, but serve as a template for Shipping Methods. This distinction makes it possible to customize individual Shipping Methods with additional information.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

Promise&#60;boolean&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;boolean&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

### withTransaction

`**withTransaction**(transactionManager?): [FulfillmentProviderService](FulfillmentProviderService.mdx)`

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "transactionManager",
    "type": "EntityManager",
    "description": "",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

[FulfillmentProviderService](FulfillmentProviderService.mdx)

<ParameterTypes parameters={[
  {
    "name": "FulfillmentProviderService",
    "type": "[FulfillmentProviderService](FulfillmentProviderService.mdx)",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />
