Skip to main content
Skip to main content

FulfillmentProviderService

Helps retrieve fulfillment providers

Constructors

constructor

**new FulfillmentProviderService**(container)

Parameters

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
fulfillmentProviderRepository_Repository<FulfillmentProvider>Required
manager_EntityManagerRequired
transactionManager_undefined | EntityManagerRequired

Accessors

activeManager_

Protected activeManager_: [object Object]

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
TResultobjectRequired
TErrorobjectRequired
Parameters
work(transactionManager: EntityManager) => Promise<TResult>Required
the transactional work to be done
isolationOrErrorHandlerIsolationLevel | (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>

PromisePromise<TResult>Required
the result of the transactional work

calculatePrice

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

Parameters
optionShippingOptionRequired
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.
dataRecord<string, unknown>Required
cartOrder | Cart
Returns

Promise<number>

PromisePromise<number>Required

canCalculate

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

Parameters
Returns

Promise<boolean>

PromisePromise<boolean>Required

cancelFulfillment

**cancelFulfillment**(fulfillment): Promise&#60;[Fulfillment](/references/services/classes/Fulfillment)&#62;

Parameters
fulfillmentFulfillmentRequired
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.
Returns

Promise<Fulfillment>

PromisePromise<Fulfillment>Required

createFulfillment

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

Parameters
methodShippingMethodRequired
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.
itemsLineItem[]Required
fulfillmentOmit<Fulfillment, "beforeInsert">Required
Returns

Promise<Record<string, unknown>>

PromisePromise<Record<string, unknown>>Required

createReturn

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

Parameters
returnOrderCreateReturnTypeRequired
Returns

Promise<Record<string, unknown>>

PromisePromise<Record<string, unknown>>Required

list

**list**(): Promise&#60;[FulfillmentProvider](/references/services/classes/FulfillmentProvider)[]&#62;

Returns

Promise<FulfillmentProvider[]>

PromisePromise<FulfillmentProvider[]>Required

listFulfillmentOptions

**listFulfillmentOptions**(providerIds): Promise&#60;[FulfillmentOptions](/references/services/types/FulfillmentOptions)[]&#62;

Parameters
providerIdsstring[]Required
Returns

Promise<FulfillmentOptions[]>

PromisePromise<FulfillmentOptions[]>Required

registerInstalledProviders

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

Parameters
providersstring[]Required
Returns

Promise<void>

PromisePromise<void>Required

retrieveDocuments

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

Fetches documents from the fulfillment provider

Parameters
providerIdstringRequired
the id of the provider
fulfillmentDataRecord<string, unknown>Required
the data relating to the fulfillment
documentType"label" | "invoice"Required
the typ of
Returns

Promise<any>

PromisePromise<any>Required
document to fetch

retrieveProvider

**retrieveProvider**(providerId): any

Parameters
providerIdstringRequired
the provider id
Returns

any

anyany
the payment fulfillment provider

shouldRetryTransaction_

Protected **shouldRetryTransaction_**(err): boolean

Parameters
errRecord<string, unknown> | { code: string }Required
Returns

boolean

booleanboolean

validateFulfillmentData

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

Parameters
optionShippingOptionRequired
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.
dataRecord<string, unknown>Required
cartRecord<string, unknown> | CartRequired
Returns

Promise<Record<string, unknown>>

PromisePromise<Record<string, unknown>>Required

validateOption

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

Parameters
optionShippingOptionRequired
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.
Returns

Promise<boolean>

PromisePromise<boolean>Required

withTransaction

**withTransaction**(transactionManager?): [FulfillmentProviderService](/references/services/classes/FulfillmentProviderService)

Parameters
transactionManagerEntityManager
Returns

FulfillmentProviderService

FulfillmentProviderServiceFulfillmentProviderServiceRequired
Was this section helpful?