Skip to main content
Skip to main content

PaymentProviderService

Helps retrieve payment providers

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
container_InjectedDependenciesRequired
customerService_CustomerServiceRequired
featureFlagRouter_FlagRouterRequired
logger_LoggerRequired
manager_EntityManagerRequired
paymentProviderRepository_Repository<PaymentProvider>Required
paymentRepository_Repository<Payment>Required
paymentSessionRepository_Repository<PaymentSession>Required
refundRepository_Repository<Refund>Required
throwFromPaymentProcessorErroranyRequired
transactionManager_undefined | EntityManagerRequired

Accessors

activeManager_

Returns

EntityManagerEntityManagerRequired

paymentService_

Returns

defaultPaymentServiceRequired

Methods

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.

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

PromisePromise<TResult>Required
the result of the transactional work

authorizePayment

Parameters

paymentSessionPaymentSessionRequired
A Payment Session is created when a Customer initilizes the checkout flow, and can be used to hold the state of a payment flow. Each Payment Session is controlled by a Payment Provider, which is responsible for the communication with external payment services. Authorized Payment Sessions will eventually get promoted to Payments to indicate that they are authorized for payment processing such as capture or refund. Payment sessions can also be used as part of payment collections.
contextRecord<string, unknown>Required

Returns

PromisePromise<undefined | PaymentSession>Required

buildPaymentProcessorContext

Build the create session context for both legacy and new API

Parameters

cartOrDataCart | PaymentSessionInputRequired

Returns

Cart & PaymentContextCart & PaymentContext

cancelPayment

Parameters

paymentObjPartial<Payment> & &#123; id: string &#125;Required

Returns

PromisePromise<Payment>Required

capturePayment

Parameters

paymentObjPartial<Payment> & &#123; id: string &#125;Required

Returns

PromisePromise<Payment>Required

createPayment

Parameters

dataCreatePaymentInputRequired

Returns

PromisePromise<Payment>Required

createSession

**createSession**(providerId, cart): Promise&#60;[PaymentSession](/references/js-client/internal/classes/internal.PaymentSession)&#62;

Parameters

providerIdstringRequired
cartCartRequired

Returns

PromisePromise<PaymentSession>Required

Deprecated

**createSession**(sessionInput): Promise&#60;[PaymentSession](/references/js-client/internal/classes/internal.PaymentSession)&#62;

Creates a payment session with the given provider.

Parameters

sessionInputPaymentSessionInputRequired

Returns

PromisePromise<PaymentSession>Required

deleteSession

Parameters

paymentSessionPaymentSessionRequired
A Payment Session is created when a Customer initilizes the checkout flow, and can be used to hold the state of a payment flow. Each Payment Session is controlled by a Payment Provider, which is responsible for the communication with external payment services. Authorized Payment Sessions will eventually get promoted to Payments to indicate that they are authorized for payment processing such as capture or refund. Payment sessions can also be used as part of payment collections.

Returns

PromisePromise<undefined | PaymentSession>Required

getStatus

Parameters

paymentPaymentRequired
A payment is originally created from a payment session. Once a payment session is authorized, the payment is created to represent the authorized amount with a given payment method. Payments can be captured, canceled or refunded. Payments can be made towards orders, swaps, order edits, or other resources.

Returns

PromisePromise<PaymentSessionStatus>Required

list

Returns

PromisePromise<PaymentProvider[]>Required

listPayments

List all the payments according to the given selector and config.

Parameters

selectorSelector<Payment>Required

Returns

PromisePromise<Payment[]>Required

processUpdateRequestsData

Process the collected data. Can be used every time we need to process some collected data returned by the provider

Parameters

dataundefined | &#123; customer?: &#123; id?: string &#125; &#125;Required
paymentResponseRecord<string, unknown> | PaymentSessionResponseRequired

Returns

PromisePromise<void>Required

refreshSession

Refreshes a payment session with the given provider. This means, that we delete the current one and create a new.

Parameters

paymentSessionobjectRequired
the payment session object to update
paymentSession.dataRecord<string, unknown>Required
paymentSession.idstringRequired
paymentSession.provider_idstringRequired
sessionInputPaymentSessionInputRequired

Returns

PromisePromise<PaymentSession>Required
the payment session

refundFromPayment

Parameters

paymentPaymentRequired
A payment is originally created from a payment session. Once a payment session is authorized, the payment is created to represent the authorized amount with a given payment method. Payments can be captured, canceled or refunded. Payments can be made towards orders, swaps, order edits, or other resources.
amountnumberRequired
reasonstringRequired
notestring

Returns

PromisePromise<Refund>Required

refundPayment

Parameters

payObjsPayment[]Required
amountnumberRequired
reasonstringRequired
notestring

Returns

PromisePromise<Refund>Required

registerInstalledProviders

Parameters

providerIdsstring[]Required

Returns

PromisePromise<void>Required

retrievePayment

Retrieve a payment entity with the given id.

Parameters

paymentIdstringRequired
relationsstring[]

Returns

PromisePromise<Payment>Required

retrieveProvider

Finds a provider given an id

Parameters

providerIdstringRequired
the id of the provider to get

Returns

TProvider extends AbstractPaymentService ? AbstractPaymentService : TProvider extends AbstractPaymentProcessor ? AbstractPaymentProcessor : anyTProvider extends AbstractPaymentService ? AbstractPaymentService : TProvider extends AbstractPaymentProcessor ? AbstractPaymentProcessor : any
the payment provider

retrieveRefund

Parameters

idstringRequired

Returns

PromisePromise<Refund>Required

retrieveSession

Return the payment session for the given id.

Parameters

paymentSessionIdstringRequired
relationsstring[]

Returns

PromisePromise<PaymentSession>Required

saveSession

Create or update a Payment session data.

Parameters

providerIdstringRequired
dataobjectRequired
data.amountnumber
data.cartIdstring
data.isInitiatedboolean
data.isSelectedboolean
data.payment_session_idstring
data.sessionDataRecord<string, unknown>Required

Returns

PromisePromise<PaymentSession>Required

shouldRetryTransaction_

Parameters

errRecord<string, unknown> | &#123; code: string &#125;Required

Returns

booleanboolean

updatePayment

Parameters

paymentIdstringRequired
dataobjectRequired
data.order_idstring
data.swap_idstring

Returns

PromisePromise<Payment>Required

updateSession

Update a payment session with the given provider.

Parameters

paymentSessionobjectRequired
The paymentSession to update
paymentSession.dataRecord<string, unknown>Required
paymentSession.idstringRequired
paymentSession.provider_idstringRequired
sessionInputCart | PaymentSessionInputRequired

Returns

PromisePromise<PaymentSession>Required
the payment session

updateSessionData

Parameters

paymentSessionPaymentSessionRequired
A Payment Session is created when a Customer initilizes the checkout flow, and can be used to hold the state of a payment flow. Each Payment Session is controlled by a Payment Provider, which is responsible for the communication with external payment services. Authorized Payment Sessions will eventually get promoted to Payments to indicate that they are authorized for payment processing such as capture or refund. Payment sessions can also be used as part of payment collections.
dataRecord<string, unknown>Required

Returns

PromisePromise<PaymentSession>Required

withTransaction

Parameters

transactionManagerEntityManager

Returns

defaultPaymentProviderServiceRequired
Was this section helpful?